SOLVED

How to prevent selected cells from printing, but have them visible?

%3CLINGO-SUB%20id%3D%22lingo-sub-1347215%22%20slang%3D%22en-US%22%3EHow%20to%20prevent%20selected%20cells%20from%20printing%2C%20but%20have%20them%20visible%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1347215%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20created%20an%20extensive%20costing%20sheet%20for%20a%20sales%20rep%20that%20gets%20filled%20in%20and%20presented%20to%20a%20customer.%3C%2FP%3E%3CP%3EPart%20of%20one%20column%20contains%20dollar%20figures%20that%20need%20to%20be%20blank%20when%20printed%2C%20but%20must%20remain%20visible%20when%20entering%20data%20on%20the%20screen.%3C%2FP%3E%3CP%3EI%20have%20been%20searching%2C%20reading%20everything%20I%20can%20to%20figure%20out%20how%20to%20achieve%20this%2C%20but%20come%20up%20empty.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20any%20way%20to%20format%20a%20cell%20to%20be%20visible%20in%20the%20sheet%2C%20but%20not%20show%20up%20when%20printed%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20is%20not%20a%20whole%20column%2C%20so%20hiding%20it%20doesn't%20work.%3C%2FP%3E%3CP%3EI%20have%20tried%20setting%20the%20print%20area%2C%20selecting%20everything%20but%20the%20certain%20cells.%20That%20doesn't%20work%20either.%20It%20breaks%20my%20sheet%20into%20multiple%20pages%20to%20print%20in%20little%20sections.%3C%2FP%3E%3CP%3EConditional%20formatting%20has%20no%20option%20for%20this.%3C%2FP%3E%3CP%3EChanging%20the%20cells%20to%20white%20font%20hides%20them%20from%20the%20user.%3C%2FP%3E%3CP%3EI%20tried%20setting%20cells%20only%20to%20hidden%2C%20but%20there%20is%20no%20option%20to%20not%20print%20hidden%20cells.%20I%20have%20looked%20everywhere%20for%20that.%3C%2FP%3E%3CP%3EI%20don't%20want%20to%20create%20macros%2C%20as%20this%20sheet%20gets%20emailed%20to%20people%20to%20fill%20in%2C%20and%20the%20antivirus%20software%20disables%20them.%20And%20besides%2C%20it%20just%20gets%20too%20complicated.%3C%2FP%3E%3CP%3ESomething%20I%20thought%20so%20simple%20has%20become%20a%20headache.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnyone%20know%20how%20to%20achieve%20this%3F%20-%20In%20a%20nutshell%2C%20certain%20cells%20visible%20but%20don't%20print.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1347215%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1347285%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20prevent%20selected%20cells%20from%20printing%2C%20but%20have%20them%20visible%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1347285%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F610377%22%20target%3D%22_blank%22%3E%40BobsYourUncle54%3C%2FA%3E%26nbsp%3BAdd%20a%20new%20cell%20style%20(see%20%3CA%20href%3D%22https%3A%2F%2Fjkp-ads.com%2Farticles%2Fstyles02.asp%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fjkp-ads.com%2Farticles%2Fstyles02.asp%3C%2FA%3E).%20Name%20the%20style%20HideWhenPrinting.%20Uncheck%20all%20boxes%20in%20the%20new%20style%20dialog%2C%20then%20click%20the%20Format%20button.%20On%20the%20Font%20tab%2C%20change%20the%20font%20to%20white%20and%20immediately%20change%20it%20back%20to%20Automatic.%20Click%20OKtwice.%3C%2FP%3E%0A%3CP%3EHighlight%20all%20cells%20which%20need%20to%20be%20absent%20from%20the%20print%20and%20set%20their%20style%20to%20the%20new%26nbsp%3BHideWhenPrinting%20style.%3C%2FP%3E%0A%3CP%3ENow%20hit%20alt%2BF11%20to%20go%20to%20the%20VBA%20Editor.%20Double-click%20on%20the%20ThisWorkbook%20module%20in%20the%20project%20explorer%2C%20past%20this%20code%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EOption%20Explicit%0A%0APrivate%20Sub%20Workbook_BeforePrint(Cancel%20As%20Boolean)%0A%20%20%20%20HideCells%0A%20%20%20%20Application.OnTime%20Now%2C%20%22'%22%20%26amp%3B%20ThisWorkbook.FullName%20%26amp%3B%20%22'!ShowAgain%22%0AEnd%20Sub%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EInsert%20a%20new%20module%20(Insert%2C%20Module%20form%20the%20menu)%20and%20paste%20this%20code%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EOption%20Explicit%0A%0ASub%20HideCells()%0A%20%20%20%20With%20ActiveWorkbook.Styles(%22HideWhenPrinting%22).Font%0A%20%20%20%20%20%20%20%20.ThemeColor%20%3D%201%0A%20%20%20%20End%20With%0AEnd%20Sub%0A%0APublic%20Sub%20ShowAgain()%0A%20%20%20%20With%20ActiveWorkbook.Styles(%22HideWhenPrinting%22).Font%0A%20%20%20%20%20%20%20%20.ColorIndex%20%3D%20xlAutomatic%0A%20%20%20%20End%20With%0AEnd%20Sub%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EThat%20should%20do%20it.%20I've%20attached%20a%20sample%20workbook%20with%20everything%20in%20place.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1347303%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20prevent%20selected%20cells%20from%20printing%2C%20but%20have%20them%20visible%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1347303%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F610377%22%20target%3D%22_blank%22%3E%40BobsYourUncle54%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESince%20you%20seem%20familiar%20with%20conditional%20formatting%2C%20let%20me%20suggest%20that%20you%20have%20a%20cell%20%22off%20camera%22%20where%20you%20can%20enter%20something%20along%20the%20lines%20of%20%22Print%22%20and%20then%20use%20conditional%20formatting%20in%20the%20subject%20cell%20so%20that%20it%20whites%20out%20the%20figure%20when%20that%20cell%20contains%20%22Print%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMy%20contingency%20planning%20mindset%2C%20though%2C%20says%20I%20need%20to%20ask%20you%20%22How%20serious%20would%20it%20be%20if%20somebody%20inadvertently%20prints%20with%20these%20figures%20visible%20and%20shows%20it%20to%20the%20customer%3F%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20ask%20because%20even%20if%20the%20probability%20is%20low%2C%20if%20it%20would%20be%20very%20serious%2C%20you%20might%20want%20to%20consider%20a%20more%20radical%20preventive%20action.%20We%20all%20get%20forgetful%20at%20times....over%20time...and%20I%20for%20one%20would%20consider%20it%20quite%20likely%20that%20the%20day%20will%20come%20when%20somebody%20innocently%20forgets%20to%20hide%20that%20cell.%20At%20that%20point--again%2C%20if%20it's%20serious--you'll%20wish%20you%20had%20done%20something%20else%3B%20like%20creating%20one%20layout%20clearly%20marked%20for%20internal%20use%20only%2C%20and%20another%20for%20customers.%20Use%20the%20same%20data--don't%20get%20redundant%20on%20that--but%20have%20two%20different%20output%20documents.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1347280%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20prevent%20selected%20cells%20from%20printing%2C%20but%20have%20them%20visible%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1347280%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F610377%22%20target%3D%22_blank%22%3E%40BobsYourUncle54%3C%2FA%3E%26nbsp%3BWhat%20come%20to%20mind%20is%20that%20you%20re-design%20your%20schedule%20so%20that%20the%20cells%20that%20should%20not%20be%20printed%20(but%20visible%20upon%20input)%20are%20outside%20the%20print%20area.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1347367%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20prevent%20selected%20cells%20from%20printing%2C%20but%20have%20them%20visible%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1347367%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F610377%22%20target%3D%22_blank%22%3E%40BobsYourUncle54%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere%20is%20an%20out-of-the-box%20solution%20you%20can%20try%20and%20see%20if%20it%20works%20for%20you.%3C%2FP%3E%3CP%3EMake%20an%20image%20file%20that%20is%20just%20a%20large%20simple%20gray%20box%2Frectangle%3C%2FP%3E%3CP%3EGo%20to%20page%20layout%20select%20background%20and%20choose%20that%20gray%20box%20file%3C%2FP%3E%3CP%3ENow%20you%20want%20to%20have%20all%20the%20data%20you%20want%20inside%20that%20gray%20box%20and%20now%20you%20can%20have%20your%20%24%24%20cells%20formatted%20in%20white%20text%20and%20still%20see%20them%20but%20then%20when%20you%20print%2C%20you%20make%20sure%20it%20doesn't%20print%20the%20background%20(which%20when%20I%20tested%20this%20solution%20I%20actually%20couldn't%20find%20how%20TO%20print%20the%20background)%3C%2FP%3E%3CP%3EI%20attached%20my%20%22gray%20box%22%20file%20(1%20less%20thing%20you%20need%20to%20do)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1347664%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20prevent%20selected%20cells%20from%20printing%2C%20but%20have%20them%20visible%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1347664%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F22322%22%20target%3D%22_blank%22%3E%40Jan%20Karel%20Pieterse%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20your%20detailed%2C%20excellent%20instructions%20here.%3C%2FP%3E%3CP%3EI%20followed%20the%20directions%2C%20all%20goes%20well%20until%20I%20bring%20up%20the%20VBA%20editor.%20It%20is%20blank%20in%20there%2C%20no%20modules%20visible.%20The%20Option%20Explicit%20etc%20module%20is%20not%20there.%3C%2FP%3E%3CP%3EPerhaps%20I%20messed%20something%20up....%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20your%20sample%20worksheet.%20It%20works%20as%20needed%2C%20perfect.%20Alt%20F11%20brings%20up%20the%20modules%20as%20you%20have%20shown%20here.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20shut%20it%20all%20down%20and%20restarted%20to%20try%20again%2C%20it%20didn't%20save%20the%20new%20style.%20I%20redid%20it%20all%20but%20same%20results.%20I%20must%20be%20missing%20something.%20I%20followed%20your%20directions%20exactly.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20I%20can%20get%20this%20working%2C%20it%20will%20be%20what%20I%20need.%20It%20has%20to%20be%20kept%20simple%20when%20I%20give%20the%20sheet%20to%20sales%20guys.%20Open%20and%20use.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1347676%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20prevent%20selected%20cells%20from%20printing%2C%20but%20have%20them%20visible%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1347676%22%20slang%3D%22en-US%22%3E%3CP%3ETo%20the%20others%20who%20replied%2C%20thank%20you%20for%20your%20thoughts%20and%20input.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20do%20have%20to%20keep%20it%20user%20simple%2C%20they%20won't%20be%20changing%20anything%20or%20formatting%20themselves.%20It%20all%20has%20to%20be%20there%20in%20the%20sheet.%20Enter%2C%20Print%2C%20Done.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1347716%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20prevent%20selected%20cells%20from%20printing%2C%20but%20have%20them%20visible%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1347716%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F22322%22%20target%3D%22_blank%22%3E%40Jan%20Karel%20Pieterse%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20just%20went%20back%20and%20tried%20again.%20I%20added%20the%20first%20module%20you%20showed%2C%20then%20the%20second%20one.%3C%2FP%3E%3CP%3EIt%20worked%20perfectly!%20Awesome%2C%20thank%20you%20for%20your%20help%2C%20I%20really%20appreciate%20that.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20can%20send%20the%20sheet%20to%20the%20sales%20guys%20now%20and%20have%20it%20not%20print%20our%20internal%20pricing%20structure%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1347760%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20prevent%20selected%20cells%20from%20printing%2C%20but%20have%20them%20visible%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1347760%22%20slang%3D%22en-US%22%3EGood%20work!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1347766%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20prevent%20selected%20cells%20from%20printing%2C%20but%20have%20them%20visible%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1347766%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F22322%22%20target%3D%22_blank%22%3E%40Jan%20Karel%20Pieterse%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20did%20the%20good%20work!%3C%2FP%3E%3CP%3EI%20just%20copied%20it!%20%3CLI-EMOJI%20id%3D%22lia_slightly-smiling-face%22%20title%3D%22%3Aslightly_smiling_face%3A%22%3E%3C%2FLI-EMOJI%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

I have created an extensive costing sheet for a sales rep that gets filled in and presented to a customer.

Part of one column contains dollar figures that need to be blank when printed, but must remain visible when entering data on the screen.

I have been searching, reading everything I can to figure out how to achieve this, but come up empty.

 

Is there any way to format a cell to be visible in the sheet, but not show up when printed?

 

It is not a whole column, so hiding it doesn't work.

I have tried setting the print area, selecting everything but the certain cells. That doesn't work either. It breaks my sheet into multiple pages to print in little sections.

Conditional formatting has no option for this.

Changing the cells to white font hides them from the user.

I tried setting cells only to hidden, but there is no option to not print hidden cells. I have looked everywhere for that.

I don't want to create macros, as this sheet gets emailed to people to fill in, and the antivirus software disables them. And besides, it just gets too complicated.

Something I thought so simple has become a headache.

 

Anyone know how to achieve this? - In a nutshell, certain cells visible but don't print.

9 Replies
Highlighted

@BobsYourUncle54 What come to mind is that you re-design your schedule so that the cells that should not be printed (but visible upon input) are outside the print area.

Highlighted
Best Response confirmed by BobsYourUncle54 (Occasional Contributor)
Solution

@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 Sub

Insert 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 Sub

That should do it. I've attached a sample workbook with everything in place.

Highlighted

@BobsYourUncle54 

 

Since you seem familiar with conditional formatting, let me suggest that you have a cell "off camera" where you can enter something along the lines of "Print" and then use conditional formatting in the subject cell so that it whites out the figure when that cell contains "Print"

 

My contingency planning mindset, though, says I need to ask you "How serious would it be if somebody inadvertently prints with these figures visible and shows it to the customer?"

 

I ask because even if the probability is low, if it would be very serious, you might want to consider a more radical preventive action. We all get forgetful at times....over time...and I for one would consider it quite likely that the day will come when somebody innocently forgets to hide that cell. At that point--again, if it's serious--you'll wish you had done something else; like creating one layout clearly marked for internal use only, and another for customers. Use the same data--don't get redundant on that--but have two different output documents.

Highlighted

@BobsYourUncle54 

Here is an out-of-the-box solution you can try and see if it works for you.

Make an image file that is just a large simple gray box/rectangle

Go to page layout select background and choose that gray box file

Now you want to have all the data you want inside that gray box and now you can have your $$ cells formatted in white text and still see them but then when you print, you make sure it doesn't print the background (which when I tested this solution I actually couldn't find how TO print the background)

I attached my "gray box" file (1 less thing you need to do)

Highlighted

@Jan Karel Pieterse 

Thank you for your detailed, excellent instructions here.

I followed the directions, all goes well until I bring up the VBA editor. It is blank in there, no modules visible. The Option Explicit etc module is not there.

Perhaps I messed something up....

 

Thank you for your sample worksheet. It works as needed, perfect. Alt F11 brings up the modules as you have shown here.

 

I shut it all down and restarted to try again, it didn't save the new style. I redid it all but same results. I must be missing something. I followed your directions exactly.

 

If I can get this working, it will be what I need. It has to be kept simple when I give the sheet to sales guys. Open and use.

 

Highlighted

To the others who replied, thank you for your thoughts and input.

 

I do have to keep it user simple, they won't be changing anything or formatting themselves. It all has to be there in the sheet. Enter, Print, Done.

Highlighted

@Jan Karel Pieterse 

I just went back and tried again. I added the first module you showed, then the second one.

It worked perfectly! Awesome, thank you for your help, I really appreciate that.

 

I can send the sheet to the sales guys now and have it not print our internal pricing structure

Highlighted
Highlighted

@Jan Karel Pieterse 

You did the good work!

I just copied it!