If Sheets("Intro").Range("CHOOSE_LED").Value = "CLASSIFIED" Then
For i = 1 To 16 '16 LEDs
Select Case i
Case 1 - 12, 16
'Do things
Case 13 - 15
'Do nothing
End Select
Next i
End If
Best practice usually says to avoid GoTo statements, if you can.You could just add goto code inside the loop to skip those numbers
[COLOR=#333333][COLOR=#333333]For i = 1 To 16 '16 LEDs
[/COLOR][/COLOR][COLOR=#333333] If i >= 13 And i <= 15 Then[/COLOR][COLOR=#333333][COLOR=#333333]
Else
'' 'main coding here
End If
next i[/COLOR][/COLOR]
I think that is precisely the issue; creating what is referred to as "spaghetti code", that can be really hard to follow and debug.Thanks Joe , what's the reasoning behind avoiding goto statements? I use them quite a lot in some of my longer code to skip around
Best practice usually says to avoid GoTo statements, if you can.
However, you can still employ your logic pretty easily without them, like this:
Code:[COLOR=#333333][COLOR=#333333]For i = 1 To 16 '16 LEDs [/COLOR][/COLOR][COLOR=#333333] If i >= 13 And i <= 15 Then[/COLOR][COLOR=#333333][COLOR=#333333] Else '' 'main coding here End Id next i[/COLOR][/COLOR]
Sorry, I had a typo.
It should be "End If", not "End Id".
I went back and updated my original reply.