Loop

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
 
G

Gary''s Student

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top