我想将所选行的值存储在动态二维数组中。
Dim values() As Variant
values=ActiveCell.EntireRow.Select
我是VBA的新手。我在行和列中都有数据。我想将特定选定行的所有值存储在数组中,然后计划进一步使用这些值。
答案 0 :(得分:0)
类似这样的事情应该可以解决:
Sub Test()
Dim COL As Long, X As Long, Y As Long
Dim MyArray() As Variant
COL = Cells(ActiveCell.Row, Columns.Count).End(xlToLeft).Column
For X = 1 To COL
ReDim Preserve MyArray(Y)
MyArray(Y) = Cells(ActiveCell.Row, X).Value
Y = Y + 1
Next X
For X = LBound(MyArray) To UBound(MyArray)
Debug.Print MyArray(X)
Next X
End Sub