Consulting

Results 1 to 3 of 3

Thread: Macro to Unhide Column, Print, Hide Cell

  1. #1
    VBAX Regular
    Joined
    Dec 2016
    Posts
    10
    Location

    Macro to Unhide Column, Print, Hide Cell

    Hello,

    Does anyone know if there is a way to insert a command button and have a hidden column unhide, open the print pop-up, select print, and return to the sheet to have said column hidden?

    Basically, I want to have a column not shown while you're working in the file, but I want it shown when it is printed.

    Thanks,

    Rob

  2. #2
    Hello,

    have you tried using the macro recorder?

    Should be able to achieve this, if not post back.
    ---------------
    Hope this helps
    ---------------

    Have been away for a very long time,
    but am popping back again (now and then).

  3. #3
    VBAX Regular
    Joined
    Mar 2017
    Posts
    7
    Location
    You could do this if it solves your need:

    First unhide the column manually and set the Print Area (etc) just the way you want it.
    Then hide it.
    Then use code like:

    Sub PrintIt()On Error GoTo errhandler
    Dim ws As Worksheet
    Set ws = ThisWorkbook.Worksheets("Sheet1")
    ws.Columns(5).Hidden = False
    ws.PrintOut
    ws.Columns(5).Hidden = True
    Exit Sub
    errhandler:
    MsgBox Err.Description, vbCritical, "  "
    Exit Sub
    End Sub
    I've used Excel for actually letters & documents type of use cases quite a bit. In fact, you can even create a custom screen that reads the printers that exist on the user's machine/network, and let them select one, and print to that printer. I've done it before. Else, just tell them to be sure their default printer has been considered before clicking your button.

Posting Permissions

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