hide columns only when printing

y481184

Board Regular
Joined
Aug 1, 2003
Messages
137
Is there any way in excel to hide a column only when the report is being printed. In other words, I have a couply of columns that I would like to keep on my report, but I don't want them to print. Do I have to manually hide each of these columns when I go to print the document?
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Try:

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Workbook_BeforePrint(Cancel <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Boolean</SPAN>)
  
  Cancel = <SPAN style="color:#00007F">True</SPAN>
  Application.EnableEvents = <SPAN style="color:#00007F">False</SPAN>
    ActiveSheet.Columns(1).Hidden = <SPAN style="color:#00007F">True</SPAN>
    ActiveSheet.PrintOut
    ActiveSheet.Columns(1).Hidden = <SPAN style="color:#00007F">False</SPAN>
  Application.EnableEvents = <SPAN style="color:#00007F">True</SPAN>
  
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Specify the columns you want hidden where I have the Columns(1) line. Put this in the ThisWorkbook module of the VBE (ALT+F11). Let me know if you have problems.
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,434
Members
448,961
Latest member
nzskater

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