statement to Exit Do if empty row

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

How do I code the statement in an Excel2000 macro to Exit Do if the entire
row is empty?
ie: If "empty row" then Exit Do
Thanks, Mike
 
Hi Mike,

Try something like:


If Application.CountA (ActiveCell.EntireRow) = 0 Then Exit Do

or

If Application.CountA (rows(10)) = 0 Then Exit Do
 
Norman,
Thanks for you help. Following is the code that I used to test the
statement:
Option Compare Text
Sub empty_row()
' empty_row Macro
Range("A1").Select ' set up a short
test
ActiveCell.Value = "a" ' with an a in
cell A1
ActiveCell.Offset(1, 1).Value = "b" ' and a b in
cell Bb2
ActiveCell.Offset(2, 2).Value = "c" ' and a c in
cell C3
Do While Application.CountA(ActiveCell.EntireRow) > 0
ActiveCell.Offset(0, 5).Value =
Application.CountA(ActiveCell.EntireRow) ' put the count in col F
ActiveCell.Offset(1, 0).Select ' move down to
the next row
i = i + 1 ' increment an
internal counter
response = MsgBox(i, 48, "Count") ' display a
MsgBox to watch the count
If i = 5 Then Exit Do ' prevent going
too far
Loop
ActiveCell.Offset(0, 5).Value =
Application.CountA(ActiveCell.EntireRow) ' this count should be 0
End Sub
 

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

Back
Top