how macro or vba to print

  • Thread starter Thread starter dlb1228
  • Start date Start date
D

dlb1228

i have an excel sheet that gets filled in with different data every week, one
week there are 20 rows the next week it maybe 11, is there a way to create a
macro or that only prints the range that i need each week
 
use a defined range name that is self adjusting to set your print area.
insert>name>define>name it something like myprintarea>in the refers to box
=offset($a$1,0,0,counta($a:$a),8)
look in the help index for OFFSET for more info
 
One option might be to record a macro. Start recording
(Tools>Macro>RecordNewMacro). Place the cursor in the upper left cell where
you're certain that you'll have data for each report. select the current area
by Ctrl-Shift-8 then set the print area using the file menu option.
I made a mock sheet with data in cells b2 through c15 and recorded a macro.
The macro recorder gave me:
Range("B2").Select
Selection.CurrentRegion.Select
ActiveSheet.PageSetup.PrintArea = "$B$2:$C$15"
This will work as long as your print area doesn't have blank rows or columns
such that Excel won't recognize it as the "CurrentRegion".
Hope this helps.
Peace.
EQC
 
My apologies, I just realized after posting that my method will always
reference the same print range since the macro recorder picked the absolute
address of the current range.
Please follow Don's advice...
 

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


Back
Top