Print a sheet using a button

  • Thread starter Thread starter Mangler
  • Start date Start date
M

Mangler

Can someone offer a snippet of code that will allow me to click a
button from and print a different sheet out?

Say I'm on sheet one, the button will print sheet 2 if I click it
 
Sub PrintTwo()
Application.ScreenUpdating = False
Worksheets("Sheet2").PrintOut
Application.ScreenUpdating = True
End Sub


Statements 1 and 3 are optional but recommended
best wsihes
 
Sub PrintTwo()
   Application.ScreenUpdating = False
   Worksheets("Sheet2").PrintOut
   Application.ScreenUpdating = True
End Sub

Statements 1 and 3 are optional but recommended
best wsihes
--
Bernard V Liengme
Microsoft Excel MVPhttp://people.stfx.ca/bliengme
remove caps from email







- Show quoted text -

Thanks! Now how do I assign that to the button itself?
 
Hi Bernard,

Comment: When a subroutine is completed the screen updating automatically
comes on so in this case you could skip the last line before End Sub?

Q? What's the advantage of turning off screen updating for a printout on a
separate sheet?

Sub PrintTwo()
Sheets("Sheet2").PrintOut
End Sub


--------

For the OP

You can use the code name of the sheet, that is, the name of the sheet as it
is displayed in the VBA area, first property of a sheet in the Properties
window, so that if the user changes the sheet name, on the Excel side, the
code will still run:

Sub PrintTwo()
Sheet1.PrintOut
End Sub

Here I am assuming the code name is Sheet1
 
Back
Top