I'm trying to learn arrays in VBA and am testing some basic concepts...
i have the following code in which the TestArrayCol sub is working but the TestArrayRow is not....getting a subscipt out of range error on the msgbox myarrayrow(j) line...i'm sure i'm overlooking something simple...any help would be appreciated...
i have the following code in which the TestArrayCol sub is working but the TestArrayRow is not....getting a subscipt out of range error on the msgbox myarrayrow(j) line...i'm sure i'm overlooking something simple...any help would be appreciated...
Code:
Sub TestArrayCol()
Dim myArrayCol As Variant, i As Integer
myArrayCol = WorksheetFunction.Transpose(Range("A1:A5"))
For i = LBound(myArrayCol) To UBound(myArrayCol)
MsgBox myArrayCol(i)
Next i
End Sub
Sub TestArrayRow()
Dim myArrayRow As Variant, j As Integer
myArrayRow = Range("B1:G1")
For j = LBound(myArrayRow) To UBound(myArrayRow)
MsgBox myArrayRow(j)
Next j
End Sub