Exclude certain cells from printing (they are inside print area)

alyssa75

Board Regular
Joined
May 14, 2007
Messages
240
I have hyperlinks in a sheet that go to other sheets in the workbook. They are not relevant when printed so I want them not to print. However, I have them placed within the print area for a clean appearance.

Any way to exclude these cells when printing?

Thanks!
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
This is the best I could come up with at short notice: In the ThisWorkbook code module, create an event handler which turns the no-print area to foreground colour white:-
Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
 
    ThisWorkbook.Sheets("Sheet1").Range("C8:F18").Font.Color = vbWhite
 
End Sub
As there's no Workbook_AfterPrint, we'll have to use some other way of turning the cells black again... maybe the Worksheet_SelectionChange handler:-
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
 
    ThisWorkbook.Sheets("[COLOR=red][B]Sheet1[/B][/COLOR]").Range("[B][COLOR=red]E10:J30[/COLOR][/B]").Font.Color = vbBlack
 
End Sub
When the printing's finished the cells will still be white but as soon as you click back on to the sheet, they'll go black again. Obviously modify the bits in red to suit your purposes and if your background and foreground colours aren't black and white to start with, you'll need to change the colour codes in the VBA.

It's all a bit clunkier than I'd have preferred but if no-one comes up with a better solution, it might do.

(I haven't tested with a real printer but it works with a PDFprinter.)
 
Last edited:
Upvote 0
Good day Ruddles,
Thanks for this. I get it right to change the text to White.... But the second part to turn it back to Black does not work for me... What could I be doing wrong?

Private Sub Workbook_BeforePrint(Cancel As Boolean)
ThisWorkbook.Sheets("Sheet1").Range("b4:E4").Font.Color = vbWhite
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ThisWorkbook.Sheets("Sheet1").Range("b4:E4").Font.Color = vbBlack
End Sub
 
Upvote 0
My post was slightly misleading. The Worksheet_SelectionChangeEvent event handler goes in the code module for the sheet you're printing. It gets triggered the next time you click on a cell in that sheet after printing.
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,856
Members
452,948
Latest member
UsmanAli786

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