March 7th, 2012, 07:04 PM
For loop question
Below is my For loop but I "Unexpected Next" error.
What am I doing wrong - any ideas?
For iPinRow = iPinNameRow+2 To usedRowsCount+1
If iPinRow.Value = "" Then
' do something
March 7th, 2012, 10:44 PM
Get rid of the embedded next statement in the if. Just comment it out and your loop should work the way you want.
Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
March 7th, 2012, 11:31 PM
Actually, I wanted to know how to go the next iteration in the For loop (I am more used to Perl than VB so tried Next for the next iteration) - since there's no such thing as Next in VB, I used an IF statement for not equal and problem solved.
March 8th, 2012, 11:08 AM
There is a Next of course you just can't put it in the middle of an If logic block.
There is an Exit For if you wanted to break out of the loop altogether.
VB also still has a GOTO but I've never encountered a use for it (except error handling) where the same thing couldn't be done with if/then or other logic.
Dim n As Integer
For n = 0 To 100
If n Mod 13 = 12 Then
“Today you are You, that is truer than true. There is no one alive who is Youer than You.” - Dr. Seuss