troubleshooting Question

Macro to set print area within Excel

Avatar of Supra_Edd
Supra_EddFlag for United Kingdom of Great Britain and Northern Ireland asked on
StorageMicrosoft Excel
2 Comments1 Solution1052 ViewsLast Modified:
I have the following macro which set's the print area to just the rows and columns that have data, or results of formula's. This works fine, but now I need it to expand the print area to the row AFTER the last bit of data. Can't seem to make it work!
Thanks

Dim lastCell As Range
Set lastCell = Cells.SpecialCells(xlCellTypeLastCell).Offset(1, 0)
Do Until Application.Count(lastCell.EntireRow) <> 0
Set lastCell = lastCell.Offset(-1, 0)
Loop
ActiveSheet.PageSetup.PrintArea = Range(Cells(1, 1), lastCell).Address
End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros