Loop

  • Thread starter Thread starter Christina
  • Start date Start date
C

Christina

I have a macro which loops and performs the functions. However it goes
around and does not stop. How do I tell it Do until there is no data in cell
or it reaches the end of data in the column.


Thanks
Cristina
 
Let's say we are processing data in oclumn C and we want to stop at either
the first empty cell in column C or the last value in column C

Sub Crissy()
Dim C As Range, r As Range
Set C = Range("C:C")
LastRow = Cells(Rows.Count, "C").End(xlUp).Row
For i = 1 To LastRow
If IsEmpty(Cells(i, "C").Value) Then Exit Sub
MsgBox Cells(i, "C").Value
Next
End Sub

So we both determine the last row and also look for the first empty as well.
 
Back
Top