VBA to set dynamic print area

Joined
Jul 29, 2011
Messages
2
Reaction score
0
I have a worksheet that has info from column A to W and the amount of data varies. I need a VBA code that will set the print area to the last row of data. However, in rows L, M & N I have sum formulas that are one row down from the last row of data. So essentially, I need a code that will set the print area from A1 to the last line of W and then go down two additional rows to capture the sum formulas. I am pretty much a novice at VBA, so the simpler the better.

Thanks
Clint
 
Joined
Jul 29, 2011
Messages
2
Reaction score
0
Never mind. I figured it out. For anyone who may come accross this same issue the code is:

Sub SetArea()
ActiveSheet.PageSetup.PrintArea = Range("A1:W1", Range("N65536").End(xlUp)).Address
End Sub

Of course, you would have to change the range but you get the idea.
 

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