VBA to Print multiple worksheets with different print ranges

AKRefugee

New Member
Joined
Apr 13, 2011
Messages
17
I know enough to be able to parse and understand a VBA code once I see it but not enough to actually know how to write it from scratch.
Really need some help here.

So let me see if I can explain.
Worksheet 1 print range a1:m36 worksheet set to landscape
Worksheet 2 print range a1:m36 worksheet set to landscape
Worksheet 3 no print range defined worksheet set to portrait

On worksheet 3 is data that applies to worksheet 1 and worksheet 2
Data related to worksheet 1 is range a1:h10
Data related to worksheet 2 is range a12:h21

Need macro to say when I print Worksheet 1 it will print preview Worksheet 3 range a1:h10 in portrait as well as include Worksheet 1 set print range a1:m36 in landscape in the same document.

The reason for the print preview instead of print out is that sometimes I will need to print hardcopy and others I will need to print as PDF.

Goal is to have Page 3 applicable data display and print in portrait as page one and Worksheet 1 (or Worksheet 2 etc) display and print in landscape as page 2 in same document in this order.

Thanks for any help you can give me on this.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Okay so I figured out a way to do this. Recorded a macro steps as follows
1. Set the print area for the landscape page
2. Set the the print area for the portrait page
3. Select both tabs
4. Print file from FILE menu
5. Select PDF printer
6. Select Print
7. Return to portrait page and select Clear Print Area from PAGE LAYOUT AREA
8. Return to landscape page and select Clear Print Area from PAGE LAYOUT AREA

The only trick is to make sure that in your workbook the worksheet tab you want to be first must be ahead (to the left) of the worksheet tab you want to be second.
 
Upvote 0
opps correction I wanted it to go to print preview then user can select output to printer or PDF themselves.

I built the macro as above then went in and edited it from PrintOut to PrintPtreview and removed everything after that.

This is what the final macro looks like.

Sub print_test()
'
' print_test Macro
'


'
Range("A1:P10").Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$P$10"
Sheets(Array("Sheet10", "Sheet11")).Select
Sheets("Sheet10").Activate
ActiveWindow.SelectedSheets.PrintPreview
End Sub



Hope this helps someone else out
 
Last edited:
Upvote 0

Forum statistics

Threads
1,217,273
Messages
6,135,590
Members
449,948
Latest member
silent_warrior52004

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top