View Full Version : Macro to Unhide Column, Print, Hide Cell

03-03-2017, 06:44 AM

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.



03-03-2017, 09:55 AM

have you tried using the macro recorder?

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

03-03-2017, 10:32 AM
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.Columns(5).Hidden = True
Exit Sub
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.