Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: Hiding cells during printing

  1. #1
    New Member
    Join Date
    Apr 2002
    Location
    London, UK
    Posts
    34
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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. #2
    Board Regular
    Join Date
    Apr 2002
    Location
    Midlands, UK
    Posts
    217
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •