For each row of my worksheet, I'm trying to browse cells. I'll stop when I encounter an empty cell. Then I want to go to the following row.
In order to do this I'm using a "Do until" loop with a "IsEmpty" condition. This "Do until" loop is inside a "For each" loop. The "For each" loop is used to go from one range to another in the first column. From A1 to A2, to A3 etc.
I manage to browse the first line successfully. But I can't manage to get down to the second row, and the following ones. I'm assuming that the "Do until" loop exits the macro without letting Excel read the "Next rng" statement...
My macro exits, and the active cell is the first empty cell of the first row. (we should now go to the second row, not stop)
Here is my code :
Sub label_clusters()
Dim rng As Range, iCounter As Integer
iCounter = 1
For Each rng In Feuil1.Range("A1:A24")
If ActiveCell.Column = 1 Then
Sheets("Feuil2").Cells(iCounter, 1) = rng.Value
Sheets("Feuil2").Cells(iCounter, 2) = rng.Offset(0, 1).Value
iCounter = iCounter + 1
ActiveCell.Offset(0, 2).Select
End If
Do Until IsEmpty(ActiveCell.Value) = True
If ActiveCell.Column <> 1 Then
Sheets("Feuil2").Cells(iCounter, 1) = rng.Value
Sheets("Feuil2").Cells(iCounter, 2) = ActiveCell.Value
iCounter = iCounter + 1
ActiveCell.Offset(0, 1).Select
End If
Loop
Next rng
End Sub
I'm obviously doing something wrong, but after googling again and againd I'm now short on ideas. Any suugestion will do =) Thanks a lot for your help.