How to identify 1st blank row in an Excel spreadsheet?

J

JoAnn

Anyone know how to do this via VBA?

I'm using a macro to define a print area by specifying
columns but I'm pulling blank rows in the resulting
printout.

Is there a way to get Excel to ignore blank rows in a
print area? In this case, the blanks are at the bottom of
the spreadsheet so if I could tell me the last row
containing data (or the first blank row), it would work.

But I may also need to find a way to skip blank rows
within a spreadsheet for another situation.

Thanks,
JoAnn
 
M

macropod

Hi JoAnn,

In Excel VBA:
LastRow = Worksheets("Sheet1").Range("A65536").End(xlUp).Row - 1

or, more crudely:
LastRow = Worksheets("Sheet1").UsedRange.Rows.Count

Change 'Sheet1' to suit your sheet's name.

Cheers
 

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

Top