I have the following code:
For x = LBound(arr) To UBound(arr)
sname = arr(x)
If InStr(sname, "Configuration item") Then
'**(here I want to go to next x in loop and not complete the code below)**
End If
'// other code to copy past and do various stuff
Next x
I thought I could simply have the statement Then Next x, but this gives a "no for statement declared" error.
What can I put after the If InStr(sname, "Configuration item") Then to make it proceed to the next value for x?
You’re thinking of a
continuestatement like Java’s or Python’s, but VBA has no such native statement, and you can’t use VBA’sNextlike that.You could achieve something like what you’re trying to do using a
GoTostatement instead, but really,GoToshould be reserved for cases where the alternatives are contrived and impractical.In your case with a single “continue” condition, there’s a really simple, clean, and readable alternative: