Macro: Print Area on a variable range of Columns and Rows

dmainou

New Member
Joined
Sep 8, 2009
Messages
2
Hi,

Could you please help me with a macro that will set the Print Area of a report based on the current lenght and width.

I have found macros that will set the Print area for reports of variable lenght but nothing for variable width.

I would love to be able to run the macro on the Active Sheet as I have several reports across a number of sheets.

Since the report is customised for the USER columns A:C are hidden as well as a large number of rows.

Your help is appreciated.

d
 
Last edited:

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
I would first define a name for the print range and make this dynamic using the offset formula and then specify in VBA to print this range.

Here is the offset formula to use:
=OFFSET(A1,0,0,COUNTA(A:A),COUNTA(1:1)

You should change A1 to the top left hand cell of your dataset (assuming it doesn't change)
You should change A:A to the column in your report that contains no blank cells
You should change 1:1 to the row where your columns headers are assuming there are no blanks.

This range will expand or contract as your data does
 
Upvote 0
Thanks,

I have found the macro to count the number of rows, but I'm struggling with the "collumn" side.

D
 
Upvote 0

Forum statistics

Threads
1,215,408
Messages
6,124,727
Members
449,185
Latest member
ekrause77

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top