I've been playing around with matrices in VBA and have been following some of the online tutorial services.
One tutorial lesson makes the student type the following code in a macro:
Dim MyArray(2, 3) As Integer
MyArray(0, 0) = 10
MyArray(0, 1) = 10
MyArray(0, 2) = 10
MyArray(0, 3) = 10
MyArray(1, 0) = 20
MyArray(1, 1) = 20
MyArray(1, 2) = 20
MyArray(1, 3) = 20
MyArray(2, 0) = 30
MyArray(2, 1) = 30
MyArray(2, 2) = 30
MyArray(2, 3) = 30
For i = 0 To 2
For j = 0 To 3
Cells(i + 1, j + 1).Value = MyArray(i, j)
Next j
Next i
When I run the program I get error message: i is an undefined variable. How do I define the index i and j variables without deleting the Option Explicit statement?
One tutorial lesson makes the student type the following code in a macro:
Dim MyArray(2, 3) As Integer
MyArray(0, 0) = 10
MyArray(0, 1) = 10
MyArray(0, 2) = 10
MyArray(0, 3) = 10
MyArray(1, 0) = 20
MyArray(1, 1) = 20
MyArray(1, 2) = 20
MyArray(1, 3) = 20
MyArray(2, 0) = 30
MyArray(2, 1) = 30
MyArray(2, 2) = 30
MyArray(2, 3) = 30
For i = 0 To 2
For j = 0 To 3
Cells(i + 1, j + 1).Value = MyArray(i, j)
Next j
Next i
When I run the program I get error message: i is an undefined variable. How do I define the index i and j variables without deleting the Option Explicit statement?