excel如何用宏代码向数组输入符合条件的数据

2025-03-06 11:42:24
推荐回答(1个)
回答1:

试试:

 Sub aa()
  Dim i As Long
  Dim n As Long
  Dim arr() As String
  For Each sht In Sheets
      For i = 1 To 100
          If sht.Cells(i, 1).Value = "a" Then
             n = n + 1
             ReDim Preserve arr(n)
             arr(n) = sht.Cells(i, 1).Value
          End If
      Next i
  Next
End Sub