Setting up a variable print range

R

Ron de Bruin

Hi Gary

Did you not see your other thread
You get a couple possible solutions there

(Posted private also)
 
T

Tod

What exactly do you mean when you say 'last row and column
used'?

A quick and dirty way is:
Range("A1:" & Range("A1").CurrentRegion.SpecialCells
(xlCellTypeLastCell).Address).PrintOut

This uses A1 to find the set of contiguous values that
make up the table of data and then prints A1 through the
cell that is in the last row and last column.

tod
 
M

MacroMan

One more possible method:

ActiveSheet.PageSetup.PrintArea = _
ActiveSheet.UsedRange.Address

Provided you save your workbook before running this code,
this would grab the smallest rectangular area of cells
that contain any data.
 
G

Gary

For example, if I enter data in a spreadsheet where I am
only using the range from A1 to L98, I want to be able to
select that range and print it. Maybe next time I use the
spreadsheet I only use the Range A1 to L16, I would like
to print only that range.

Gary
 
T

Tom Ogilvy

ActiveSheet.PageSetup.PrintArea = _
Range("A1").CurrentRegion.Address(external:=true)

Put it in the BeforePrint event.

Regards,
Tom Ogilvy
 

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