View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Olle Svensson
 
Posts: n/a
Default Macro for hiding and printing.

Thanks, but unfortunately, that did not work at all. I've been trying to use
this:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Sheet1" Then
Cancel = True
Application.EnableEvents = False
Application.ScreenUpdating = False
With ActiveSheet
.Range("W1,AC1").EntireColumn.Hidden = True
.PrintOut
.Range("W1,AC1").EntireColumn.Hidden = False
End With
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End Sub

Maybe I am doing it wrong, but I go to the Microsoft Visual Basic, paste it
under Microsoft Excel Objects -- ThisWorkbook, save and exit to Excel. Then
I press the print button but nothing happens. Well, the print comes out but
with the undesired columns still visible.

If it's not possible to tie it to the print button (or File -- Print) then
would it be possible to make a macro of it that I can assign to a button on
one of the sheets?



"Dave Peterson" wrote:

Like this?

Option Explicit
Sub testme()

Dim wks As Worksheet

For Each wks In ActiveWorkbook.Worksheets
wks.Range("w:ac").EntireColumn.Hidden = True
Next wks

ActiveWorkbook.PrintOut preview:=True 'save paper for testing

For Each wks In ActiveWorkbook.Worksheets
wks.Range("w:ac").EntireColumn.Hidden = False
Next wks

End Sub



Olle Svensson wrote:

Hi.
I want to put in a macro that simply hides columns W-AC in all sheets and
then prints the entire workbook. Sounds rather easy but being a rookie at
macros, I can not do it myself.

Therefore, I hope someone might be able to throw something together for me,
please?

Kind regards,
Olle Svensson


--

Dave Peterson