Hiding cells during printing

lmc_budd

New Member
Joined
Apr 29, 2002
Messages
34
I need to hide specific cells in an Excel 2000 spreadsheet so that they do not appear on the printed output, but leave them otherwise unaffected on screen. How can this be achieved?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Try this code in the ThisWorkbook Module. It doesn't actuall "hide" the cell, but it makes the contents invisible.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Range("asdf").Select
Selection.NumberFormat = ";;;"
Application.OnTime Now + TimeValue _("00:00:05"), "ThisWorkbook.AfterPrint"
End Sub

Private Sub AfterPrint()
Range("asdf").Select
Dim cel1 As Range
For Each cel1 In Selection
If Selection.NumberFormat = ";;;" Then
Selection.NumberFormat = "General"
End If
Next cel1
End Sub

You will need to do a couple of things to get it to work :
Apply a defined name of "asdf" ( can change to what ever you like) to the cells you want hidden before printing.
Change the TimeValue to suite - this waits 5 seconds before setting the format back. Should be enough time to print.
The secind code returns the cell format to General, so if you have different formats in different "hidden" cells you will need to apply defined names to each format.

HTH

Iain
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,237
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top