Is there a way not to print a specific word or cell

ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Is there a way not to print a specific word or cell

Post by ABabeNChrist »

Is there a way not to print a specific word or cell? using code or not. Let say I have the word spot in cell A1 that I want to leave on my sheet but do not wish to have it print.

User avatar
HansV
Administrator
Posts: 78524
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Is there a way not to print a specific word or cell

Post by HansV »

You could set the text color of the cell(s) to the same as the fill (background) color. This will make the text invisible both on screen and in a printout.
Alternatively, you could hide the row or column containing the cell.
Best wishes,
Hans

User avatar
Don Wells
5StarLounger
Posts: 689
Joined: 27 Jan 2010, 16:45
Location: Ottawa, Ontario, Canada

Re: Is there a way not to print a specific word or cell

Post by Don Wells »

ABabeNChrist wrote:Is there a way not to print a specific word or cell? using code or not. Let say I have the word spot in cell A1 that I want to leave on my sheet but do not wish to have it print.
One approach using code would be to:
  • copy the sheet to a new sheet
  • do a search and replace on the new sheet, replacing the word or phrase of interest with nothing ("")
  • print the new sheet
  • delete the new sheet
H.T.H.
Regards
Don

User avatar
Leif
Administrator
Posts: 7209
Joined: 15 Jan 2010, 22:52
Location: Middle of England

Re: Is there a way not to print a specific word or cell

Post by Leif »

HansV wrote:You could set the text color of the cell(s) to the same as the fill (background) color. This will make the text invisible both on screen and in a printout.
I don't think that will work when printing in 'Black and white' mode - certainly not in my Excel 2002...
Leif

User avatar
HansV
Administrator
Posts: 78524
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Is there a way not to print a specific word or cell

Post by HansV »

No, in B&W mode, Excel will print the text even if it is white...
Best wishes,
Hans

ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Re: Is there a way not to print a specific word or cell

Post by ABabeNChrist »

I first attemped in using

Code: Select all

            With ActiveSheet
                .Range("A1").Value = ""
                .PrintOut
                .Range("A1").Value = "Spot"
            End With
This is not exactly what I was hoping for. I was hoping to format a single cell so that text would and could be visible but would not print. Like a form control, you can see it but you don’t have to print it. This way printing would not necessarily need code to hide text

User avatar
HansV
Administrator
Posts: 78524
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Is there a way not to print a specific word or cell

Post by HansV »

ABabeNChrist wrote:I was hoping to format a single cell so that text would and could be visible but would not print.
That is not possible, so you'll have to use a workaround.
Best wishes,
Hans

ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Re: Is there a way not to print a specific word or cell

Post by ABabeNChrist »

I guess a workaround it is
Thank you Hans, Don and Leif

User avatar
StuartR
Administrator
Posts: 12612
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Is there a way not to print a specific word or cell

Post by StuartR »

ABabeNChrist wrote:I guess a workaround it is...
Another workaround might be to insert a borderless white rectangle in front of the cell

Code: Select all

Dim shp As Shape

With ActiveSheet.Range("D4")
    Set shp = ActiveSheet.Shapes.AddShape(msoShapeRectangle, .Left, .Top, .Width, .Height)
End With

shp.Fill.ForeColor.RGB = RGB(255, 255, 255)
shp.Line.Visible = msoFalse
StuartR


ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Re: Is there a way not to print a specific word or cell

Post by ABabeNChrist »

Thank you StuartR
thats not a bad idea
I will weight out all my options and see what works best in my application :grin:

Jim Cone
StarLounger
Posts: 78
Joined: 18 Feb 2010, 01:44

Re: Is there a way not to print a specific word or cell

Post by Jim Cone »

A custom number format of ";;;" hides a cell entry without altering the cell contents.
You can use the workbook Before Print event code to format the cell(s), print the sheet and then revert to the original number format.
'---
Jim Cone
Portland, Oregon USA
https://goo.gl/IUQUN2" onclick="window.open(this.href);return false; (Dropbox)
(free and commercial excel workbooks & add-ins)