LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default How to show columns/cells in sheet but hide them in print?

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shortcut for hide/show detail in grouped columns/rows Corey Excel Discussion (Misc queries) 1 November 20th 07 12:06 AM
Hide n' show cells in protected sheet Excellgreenhorn Excel Worksheet Functions 1 October 27th 07 12:38 AM
Macro to hide/show rows and columns Leo Excel Discussion (Misc queries) 4 May 23rd 06 05:25 PM
Showing + and - (show and hide) for rows in the sheet Kurt Excel Worksheet Functions 1 November 10th 05 12:53 PM
how can hide and show columns using macro? Hoshyar Excel Worksheet Functions 4 September 2nd 05 03:45 PM


All times are GMT +1. The time now is 09:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"