How do I create a print macro in Excel

November 26, 2010 at 11:46:38
Specs: Windows Vista
I have a spreadsheet (Called "Expenses") with 3 (A,B,C) tabs. How do I create a macro to print all tabs.

KOmegah


See More: How do I create a print macro in Excel

Report •

#1
November 26, 2010 at 19:46:36
re: "I have a spreadsheet (Called "Expenses") with 3 (A,B,C) tabs."

I assume that you mean you have workbook called "Expenses" with 3 sheets named A, B and C.

1 - Press Alt-F11 to open the VBA editor.
2 - In the left hand pane, Double Click the word "ThisWorkbook"
3 - Paste in the following code

Whenever you Print the workbook, the code will "intercept" the Print command and run, printing every sheet in the workbook.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
 Application.EnableEvents = False
   For shts = 1 To Sheets.Count
     Sheets(shts).PrintOut
   Next
  Cancel = True
 Application.EnableEvents = True
End Sub

Posting Tip: Before posting Data or VBA Code, read this How-To.


Report •
Related Solutions


Ask Question