Hello,
I am trying to use a Do loop for the first time and having some difficulty
I want to exit the Do loop when
and advance to the next row
My code only works for the irow = 2, it does not advance i.e. next irow does not seem to be read or executed
The For loop is not working and not sure why
The Do loop is giving me what I want
Thanks for any help on this
I am trying to use a Do loop for the first time and having some difficulty
I want to exit the Do loop when
Code:
.Cells(irow, icol) = ""
My code only works for the irow = 2, it does not advance i.e. next irow does not seem to be read or executed
The For loop is not working and not sure why
The Do loop is giving me what I want
Thanks for any help on this
Code:
Sub testDoLoop()
Dim ws As Worksheet
Dim cnt As Long, irow As Long, icol As Long, LR As Long, LC As Long
Set ws = ThisWorkbook.Sheets("Elements")
LC = 149
LR = 276
cnt = 1
icol = 13
With ws
For irow = 2 To LR
Do While icol <= LC
If .Cells(irow, icol) <> "" Then
.Cells(irow, icol).value = "sm-" & cnt & "|" & .Cells(irow, icol).value
cnt = cnt + 1
icol = icol + 9
Else
Exit Do
End If
Loop
Next irow
End With
End Sub