shabbyporpoise
New Member
- Joined
- Jul 22, 2011
- Messages
- 26
Hello forum
I am struggling with why I am getting "subscript out of range" error. My loop iterates the first time through for which ever value the user has selected for "num" once it gets to the end however I get the error. What I want to be happening is that every item is matched against the first item and then loops so that every item is matched against the second item and so on. Please help
I am struggling with why I am getting "subscript out of range" error. My loop iterates the first time through for which ever value the user has selected for "num" once it gets to the end however I get the error. What I want to be happening is that every item is matched against the first item and then loops so that every item is matched against the second item and so on. Please help
Code:
sub example()
(declared variables, and working array (rules()))
a=1
x=1
i=1
For x = 2 To num
For i = 2 To num
If rules(i, 3) = rules(i - a, 3) Then
MsgBox rules(i, 3) & "found a match" & rules(i - a, 3)
Else
MsgBox rules(i, 3) & " no match " & rules(i - a, 3)
End If
a = a + 1
Next i
If Cells(i, 3) = "" Then
MsgBox "next item"
i = i + 1
End If
Next x
End Sub