Print Range

M

manfareed

I have finance spreadsheets i.e. P&L’s for different countries. Each of the
spreadsheets has a different last column which has data in it. These reports
are generated from our finance reporting tool. Instead of manually setting a
print range, is there a way of using VBA to set the range which takes into
account the last column with data. The last row in all cases should be
“710â€.[egs of print areas : .PrintArea = "$A$1:$BM$710" ; .PrintArea =
"$A$1:$BA$710"]
I don’t know what the print range will be until the report has been ran. I
wish to attach the “macro†to the blank template which is used by the
reporting tool. When a country specific report is ran the relevant columns
will be “populatedâ€.

Thanks
 
S

Sam Wilson

This will work:

Sub demo()

Dim ws As Worksheet
Set ws = ActiveSheet

ws.PageSetup.PrintArea = ws.Range("a1").Resize(710,
ws.Cells.SpecialCells(xlCellTypeLastCell).Column).Address

End Sub
 
M

manfareed

Many Thanks ... It works

Sam Wilson said:
This will work:

Sub demo()

Dim ws As Worksheet
Set ws = ActiveSheet

ws.PageSetup.PrintArea = ws.Range("a1").Resize(710,
ws.Cells.SpecialCells(xlCellTypeLastCell).Column).Address

End Sub




manfareed said:
I have finance spreadsheets i.e. P&L’s for different countries. Each of the
spreadsheets has a different last column which has data in it. These reports
are generated from our finance reporting tool. Instead of manually setting a
print range, is there a way of using VBA to set the range which takes into
account the last column with data. The last row in all cases should be
“710â€.[egs of print areas : .PrintArea = "$A$1:$BM$710" ; .PrintArea =
"$A$1:$BA$710"]
I don’t know what the print range will be until the report has been ran. I
wish to attach the “macro†to the blank template which is used by the
reporting tool. When a country specific report is ran the relevant columns
will be “populatedâ€.

Thanks
 

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