I want my programme to jump to Err 1 when it detects an error in this loop, but this doesn't seem to be working (i.e. I still get run-time error message '13'). Can anyone spot any problem with my syntax?
Private Sub groups_Click()
On Error Resume Next
For i = 0 To 100
market.attribute.Selected(i) = False
Next i
For i = 1 To 100
market.attribute.RemoveItem 0
Next i
On Error GoTo 0
'Below is the one I have a problem with - if it detects an error in the loop below I want it to jump to Err1 (i.e. go to next n).
On Error GoTo Err1
For n = 3 To 65000
If seg_data.Cells(n, 10) = "" Then
Exit For
End If
If seg_data.Cells(n, 4) = market.Company.Value And seg_data.Cells(n, 5) = market.main.Value And seg_data.Cells(n, 6) = market.groups.Value Then
market.attribute.AddItem seg_data.Cells(n, 7)
End If
Err1:
Next n
market.Activate
End Sub
Private Sub groups_Click()
On Error Resume Next
For i = 0 To 100
market.attribute.Selected(i) = False
Next i
For i = 1 To 100
market.attribute.RemoveItem 0
Next i
On Error GoTo 0
'Below is the one I have a problem with - if it detects an error in the loop below I want it to jump to Err1 (i.e. go to next n).
On Error GoTo Err1
For n = 3 To 65000
If seg_data.Cells(n, 10) = "" Then
Exit For
End If
If seg_data.Cells(n, 4) = market.Company.Value And seg_data.Cells(n, 5) = market.main.Value And seg_data.Cells(n, 6) = market.groups.Value Then
market.attribute.AddItem seg_data.Cells(n, 7)
End If
Err1:
Next n
market.Activate
End Sub