shabbyporpoise
New Member
- Joined
- Jul 22, 2011
- Messages
- 26
Hello Forum
I am trying to loop through a doc. I want to test/match every item in the column against the first item, then loop and then test/match every item against the second item...and so on... and so on. I can successfully go through one column all the way to the end testing every item against the first item but when I get to the end of the list I get a run-time error 9 "subscript out of range" What am I missing?
I am trying to loop through a doc. I want to test/match every item in the column against the first item, then loop and then test/match every item against the second item...and so on... and so on. I can successfully go through one column all the way to the end testing every item against the first item but when I get to the end of the list I get a run-time error 9 "subscript out of range" What am I missing?
Code:
Sub testArray()
Dim rules(1 To 10000, 1 To 6) As String
Dim intRow As Integer, intColumn As Integer, num As Integer
Dim i As Integer, a As Integer, x As Integer
num = InputBox("how many?")
i = 1
a = 1
x = 1
For intRow = 1 To num
For intColumn = 1 To 6
rules(intRow, intColumn) = Cells(intRow, intColumn).Value
Next intColumn
Next intRow
For x = 2 To num
For i = 2 To num
If rules(i, 3) = rules(i - a, 3) Then '(error occurring here)
MsgBox "found a match"
Else
MsgBox rules(i, 3) & " no match " & rules(i - a, 3)
End If
a = a + 1
Next i
i = i + 1
Next x
End Sub