Solved EXCEL - create print button

HP
November 16, 2008 at 17:38:33
Specs: xp, /2 B
Could anyone tell me how to create a separate button within the worksheet to print a selected area rather from selecting from the print area in the menu bar. eg print only from A1 to G5 when the manual button is clicked.
Many Thanks!

See More: EXCEL - create print button

Report •


#1
November 16, 2008 at 19:48:38
✔ Best Answer
This code will save the current PrintArea, set the PrintArea to A1:G5, Print the sheet and then restore the original PrintArea.

Sub MyPrint()
curPrtArea = ActiveSheet.PageSetup.PrintArea
myPrtArea = "A1:G5"
ActiveSheet.PageSetup.PrintArea = myPrtArea
ActiveSheet.PrintOut
ActiveSheet.PageSetup.PrintArea = curPrtArea
End Sub

To create a button, you can either:
- Create a shape in the workbook
- Right Click it
- Choose Assign macro
- Pick the MyPrint

or

- Use Tools...Customize
- Click the Commands tab
- Scroll down to Macros
- Grab the Custom Button and drag it to a tool bar.
- Right click the button
- Assign the Macro, Edit the picture, Edit the name, etc.
- Close the Customize box


Report •
Related Solutions


Ask Question