Home |
Search |
Today's Posts |
#8
![]()
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi JLG.
Would it not be more effective to make the Font.ColorIndex = xlNone? Thank you for your query. Whilst a cell's fill colour may be set to xlNone, I do not think that this value has a useful significance for the cell's font index. In fact, the intent was temporarily to remove any fill colour and hide any text by setting each to white (2) and , after the print operation, restore the memorised values. As a result of your question, I reviewed my response and realised that the code was not that which I had intended to post. Thank you again. --- Regards. Norman "JLGWhiz" wrote in message ... I think the default for Interior.ColorIndex = xlNone. Would it not be more effective to make the Font.ColorIndex = xlNone? "Norman Jones" wrote: Hi Jeff, Apologies if this shows up twice but I am unable to locate my original response. In the ThisWorkbook module (see below), try: '============= Option Explicit '-------------------- Private Sub Workbook_BeforePrint(Cancel As Boolean) Dim SH As Worksheet Dim rCell As Range Dim i As Long Dim j As Long Set SH = Me.Sheets("Sheet1") '<<==== CHANGE Set Rng = SH.Range("A2, A4, A6") '<<==== CHANGE ReDim Arr(1 To Rng.Cells.Count) For Each rCell In Rng.Cells j = j + 1 Arr(j) = rCell.Interior.ColorIndex Next rCell Rng.Interior.ColorIndex = xlNone Application.OnTime Now, "AfterPrint" End Sub '<<============= Change: Set Rng = SH.Range("A2, A4, A6") '<<==== CHANGE to reflect the cells of interest. This is workbook event code and should be pasted into the workbook's ThisWorkbook module *not* a standard module or a sheet module: Right-click the Excel icon on the worksheet (or the icon to the left of the File menu if your workbook is maximised) Select 'View Code' from the menu and paste the code. Alt-F11 to return to Excel. In a standard module (see below), paste the following code: '============= Option Explicit Public Rng As Range Public Arr() As Long '-------------------- Public Sub AfterPrint() Dim rCell As Range Dim j As Long For Each rCell In Rng.Cells j = j + 1 rCell.Interior.ColorIndex = Arr(j) Next rCell End Sub '<<============= Alt-F11 to open the VBA Editor Menu | Insert | Module Paste the above code Alt-F11 To return to Excel Save the file. --- Regards, Norman "Jeff Korn" wrote: I have an Excel 2003 worksheet with some content. One column - or more prceisely a couple of cells) should be displayed but not printed (on paper). How can I achieve this? Or alternatively is there a way to temporarily hide a range of cells in visual sheet and printed version? Jeff |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Shortcut for hide/show detail in grouped columns/rows | Excel Discussion (Misc queries) | |||
Hide n' show cells in protected sheet | Excel Worksheet Functions | |||
Macro to hide/show rows and columns | Excel Discussion (Misc queries) | |||
Showing + and - (show and hide) for rows in the sheet | Excel Worksheet Functions | |||
how can hide and show columns using macro? | Excel Worksheet Functions |