Thread: Loop
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Loop

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.
--
Gary''s Student - gsnu201001


"Christina" wrote:

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