![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Location: London, UK
Posts: 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?
|
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Apr 2002
Location: Midlands, UK
Posts: 217
|
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 |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|