VBA Code

  • Thread starter Thread starter Pasha
  • Start date Start date
P

Pasha

As a part of a Macro, I am setting up the printing area by:

ActiveSheet.PageSetup.PrintArea = "$A$1:$S$579"

However, the target file is not static, last row might change
depending on number of records I have. How do I setup the last row t
be the last non blank row in Active Sheet? I don't want to select th
entire sheet (A:S), because it will have many blank pages
 
one way:

With ActiveSheet
.PageSetup.PrintArea = .UsedRange.Columns("A:S").Address
End With
 
If you don't have blank rows or columns in your print
area, you could write code to select cell A1, then use
Selection.CurrentRegion.Select.

Another idea would be to give a range name to the print
area, and use the Resize method to expand it by one row
when you add the new row of data.
 

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