Is it somehow possible in VBA to put a For
and If
statement in a single line?
The closest what I could get is this:
For i = 0 To n: If a = i Then a = b
Next i
If I write:
For i = 0 To n: If a = i Then a = b: Next i
I get the "Next without For" error.
You can do it with IIf
, rather than If
.
This code won't throw the error:
For i = 0 To n: IIf a = i, a = b, False: Next i
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With