### when you print

eluna

Board Regular
Joined
May 30, 2005
Messages
92
Is there a way to automatically adjust the columns so when they print, ###### do not show. I have several sheets that values change constantly and need to be print in one page per sheet.

Thanks
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hello there eluna,

Yes, this is possible. That means 1 of 2 things, either 1) your data does not fit within the alloted column width or 2) you have negative time values. If it is caused by reason 1, you can use something like this ...


<font face=Tahoma 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>)
    Cells.EntireColumn.AutoFit
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>


With the file open, directly to the left of the File menu item, right click the little workbook icon and select View Code. Paste the code in the right pane. Note that only one Before_Print event is allowed per workbook, so if you already have one they will need to be merged.

Note that you should already know about how this will impact your sheet. If you have columns that autofit to a very large area you may have some funky results when you print.
 
Upvote 0

Forum statistics

Threads
1,203,690
Messages
6,056,755
Members
444,889
Latest member
ibbara

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