Restricting Cell from being Printed

  • Thread starter Thread starter Denis
  • Start date Start date
D

Denis

I have created a simple table based form in Excel.
I want some cells to be printed fully black if nothing is entered in it.

Is there any way, I can do this?

Thanks in Advance!

Regards,
Denis
 
Before printing:

Format > Cells... > Patterns > Color
and pick the same as the font color

After Printing, reverse this.

You can do it manually, or with a macro.
 
Try Format>Conditional Formatting to set the blank cells to black, although
would be black even when not printing.

Or run a macro to color the cells black before printing then undo after
printing.

Sub printblack()
For Each cell In Selection
If cell.Value = "" Then
cell.Interior.ColorIndex = 1
End If
Next cell
End Sub

Sub undoprintblack()
For Each cell In Selection
If cell.Value = "" Then
cell.Interior.ColorIndex = xlnone
End If
Next cell
End Sub


Gord Dibben MS Excel MVP
 
Private Sub Workbook_BeforePrint(Cancel As Boolean)
With ActiveSheet.Range("A1")
If .Value = "" Then
.Interior.ColorIndex = 1
Else
.Interior.ColorIndex = xlNone
End If
End With
End Sub

Right-click on the Excel Icon left of "File" and select "View Code"

Copy/paste the above into that module.

Edit the Range("A1") to suit.

Alt + q to return to the Excel window.


Gord
 
Thanks Gord for your Valued Reply.

But, this code is not working. I just changed the cell range from "A1"
to "C8". And kept the cell "C8" blank. But, it didnot filled it with
black colour. It printed it blank (colourless).

Thanks in Advance.

Regards,
Denis
 
Are you sure C8 is blank?

No extra <space" or?

Did you place the code into Thisworkbook module?

Tested with C8 and works fine at this end.......Excel 2003


Gord
 
Also you may want to place this code in Thisworkbook module.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("yoursheetname").Range("C8").Interior.ColorIndex = xlNone
End Sub


Gord
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top