Dynamic print range with hidden columns

dareman93

New Member
Joined
Jun 2, 2014
Messages
28
We have a large workbook with multiple sheets, one for each project. Each sheet is a billing summary for that project. The sheets are all based on a hidden template sheet that is copied and then filled out and formatted using some VBA and data entered for the project on a User Form. This all works fine.

The problem I'm having is that I'd like to set the template sheet up so that there is a defined print range that doesn't have to be changed every month by the user. When the sheet is created, it is set up for 12 months worth of billing (most projects are done within 6 months, so 12 gives us enough flexibility that I haven't had to add on to the end yet). When we print the sheets for the month, all we are interested in is the last month worth of billing data. We have been doing this by hiding columns and updating the print range each month, but I would like to automate this so the print range does not have to be updated manually each month.

Let me see if this example will help. Pretend that my spreadsheet consists of 9 rows and 26 columns (A through Z). Columns A and B contain equipment information and the date it was installed (and removed, if applicable) and should be printed out every time. Columns C through Z contain monthly data, with 2 columns per month (i.e. month 1 data is in Columns C and D, month 2 data is in Columns E and F, month 3 data is in Columns G and H, and so on until month 12, which is in Columns Y and Z).

After the first month, when it comes time to bill the client, we would want the print range to be from A1 to D9. After the second month, we hide Columns C and D and want the print range to be from A1 to F9 (with columns C and D hidden and, thus, not printing out). After month 3, Columns C through F are hidden and the print range is A1 to H9 (again with columns C through F not printing out). And so on until month 12 when the print range is A1 to Z9 with Columns C through X hidden and not printing out).

I have tried simply setting the print range to be Columns A through D, hoping that when Columns C and D are hidden, Excel would jump to E and F and treat them like C and D, but that doesn't work. It just prints out columns A and B.

I also tried using an offset command to define the print area (I found an article detailing that you can set the print range, which basically defines a named range, then use the Name Manager to enter a formula including an offset to tell Excel how many rows or columns to include). That mostly worked, but there is no way to automatically have Excel know how far out to set the print range (i.e. it doesn't know it is now month 3 unless I set a cell equal to 3 somewhere and read that in to the Offset command).

Does anyone have an idea of how I can make this work without requiring the user to update what month it is and using the offset command I previously tried?

Thanks!
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,214,917
Messages
6,122,233
Members
449,075
Latest member
staticfluids

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