B brittonsm Jun 4, 2008 #1 How do I take a selection of cells on the sheet and load them into an Array in VBA? -Steve
J JE McGimpsey Jun 4, 2008 #3 One way: Dim vArr As Variant vArr = Range("A1:J10").Value which loads the values in the range into a (1 To 10, 1 to 10) variant array.
One way: Dim vArr As Variant vArr = Range("A1:J10").Value which loads the values in the range into a (1 To 10, 1 to 10) variant array.
A Alan Beban Jun 5, 2008 #4 brittonsm said: How do I take a selection of cells on the sheet and load them into an Array in VBA? -Steve Click to expand... You've received two valid answers for a Variant() array or an array contained within a Variant variable. If that is not your situation, post back. Alan Beban
brittonsm said: How do I take a selection of cells on the sheet and load them into an Array in VBA? -Steve Click to expand... You've received two valid answers for a Variant() array or an array contained within a Variant variable. If that is not your situation, post back. Alan Beban
G Gary''s Student Jun 5, 2008 #5 In the worst case, if your selection is a pile on non-contiguous cells, then: Sub sel_to_array() Dim ar() As Variant ReDim ar(1 To Selection.Count) As Variant i = 1 For Each r In Selection ar(i) = r.Value i = i + 1 Next End Sub
In the worst case, if your selection is a pile on non-contiguous cells, then: Sub sel_to_array() Dim ar() As Variant ReDim ar(1 To Selection.Count) As Variant i = 1 For Each r In Selection ar(i) = r.Value i = i + 1 Next End Sub