If there are certain cells on your worksheet that you don’t want to print, you can hide the rows or columns they’re in before you print. Sometimes, however, there is other information in those rows and columns that you DO want to print.
There is no facility to hide individual cells, but you can change the color of the text to match the background of the cell. I’ll show you how I do it, but it’s not the only way (or the best way necessarily).
First, I create a style (Format>Style) called PrintWhite. If the background of your cells isn’t white, you’ll have to adjust this example to suit your particulars. I base the style on the Normal style, that is, I select a cell with the Normal style before creating PrintWhite. My style box looks like this:
As you can see, I uncheck all the boxes except font. I didn’t need to do that for this example, but since I know that the only attribute I will be changing is the font, I did it anyway.
Next, change the style for each cell that you want to hide while printing. In this example, I changed the style of all the even numbers to PrintWhite and left the odd numbers Normal.
Finally, you’ll need some code in your WorkBook_BeforePrint event. (Alt-F11 to open the VBE, double click on ThisWorkbook under your project in the Project Explorer, and select Workbook and BeforePrint from the dropdown boxes).
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Application.EnableEvents = False
Cancel = True
Me.Styles("PrintWhite").Font.Color = vbWhite
Me.Styles("PrintWhite").Font.ColorIndex = xlColorIndexAutomatic
Application.EnableEvents = True
The above event procedure changes the font color of the style to white, prints, then changes the color back to automatic.