I have a data that looks like this, the amount of empty rows might increase or decrease and is not fixed.
What I want to do is to turn it to this, to delete the empty row until there is data and make it stop. I do not want it to remove other empty rows that might be in the middle of the data.
I have been testing on something and this is what I have, however this code does not clear all the empty rows, but only a few. I realized that the problem might be using the for each cell in rng way, as it will continue to the next cell when I use cell.entirerow.delete, but I might be wrong.
Sub Test()
Dim cell as range, rng as range
Dim lRow as long
Set rng = Range("C3:C" & lRow)
For Each cell In rng
If IsEmpty(cell.Offset(-1)) Then
cell.Offset(-1).EntireRow.Delete
Else
Exit For
End If
Next cell
End Sub
Thank you for helping out


Forloops. This will ensure that all rows will be deleted. UsingFor Eachwill ensure that you increment, hence not deleting all.