Forum Discussion
How to prevent selected cells from printing, but have them visible?
- Apr 29, 2020
BobsYourUncle54 Add a new cell style (see https://jkp-ads.com/articles/styles02.asp). Name the style HideWhenPrinting. Uncheck all boxes in the new style dialog, then click the Format button. On the Font tab, change the font to white and immediately change it back to Automatic. Click OK twice.
Highlight all cells which need to be absent from the print and set their style to the new HideWhenPrinting style.
Now hit alt+F11 to go to the VBA Editor. Double-click on the ThisWorkbook module in the project explorer, past this code:
Option Explicit Private Sub Workbook_BeforePrint(Cancel As Boolean) HideCells Application.OnTime Now, "'" & ThisWorkbook.FullName & "'!ShowAgain" End SubInsert a new module (Insert, Module form the menu) and paste this code:
Option Explicit Sub HideCells() With ActiveWorkbook.Styles("HideWhenPrinting").Font .ThemeColor = 1 End With End Sub Public Sub ShowAgain() With ActiveWorkbook.Styles("HideWhenPrinting").Font .ColorIndex = xlAutomatic End With End SubThat should do it. I've attached a sample workbook with everything in place.
Unfortunately, Excel doesn’t have a built-in feature to show a cell on-screen but automatically hide it when printing without using VBA. However, there are a few workarounds that don’t require macros:
1. Use a Custom Print Area
Copy your sheet to a new sheet just for printing.
Remove or hide the sensitive cells/column in this print-only version.
Print from the new sheet while keeping your original sheet intact.
2. Use White Font on Print
If you can ensure the printed background is white, you can conditionally format the cells to white font only when printing.
Steps:
Select the cells.
Format → Font → White color.
They remain visible on screen if you set the sheet background color to a light gray or another color, so the user sees the data, but the printer sees white text.
3. Create a “Print-Friendly” Version Using Formulas
On a separate sheet, replicate the layout using formulas like =IF(printing=1,"",A1).
Before printing, set a cell named printing to 1. This hides the sensitive values in the print version, while your main sheet remains unchanged.