Print dynamic ranges each from different sheets in 1 go ?

Paul Sansom

Board Regular
Joined
Jan 28, 2013
Messages
178
Office Version
  1. 2021
  2. 2016
Platform
  1. Windows
Hi
Trying to Print dynamic ranges from different sheets in one print run.
I have the code below but I cant see why I doesn't populate, and I get an object error.
Guidance always appreciated
Code:
Sub PrintAllDataSheets()
'   Print Initiate Investigate Validate Audit Implement Summary Page in sigle report
    
    Dim arrSheets
    Dim arrAreas
    Dim i As Integer
    
    arrSheets = Array("Initiate", "Investigate", "Validate", "Audit", "Implement")
    arrAreas = Array("Print_Initiate", "Print_Investigate", "Print_Validate", "Print_Audit", "Print_Implement")
    
    For i = 0 To UBound(arrSheets)
    Sheets(arrSheets(i)).PageSetup.PrintArea = arrAreas(i)

    arrAreas(i).PrintOut
    Next
    
End Sub

I also have an alt version with more print control . Same error , but also not sure if I can do this????
Pointers on feasibility appreciated???

Code:
Sub PrintAllDataSheets1()
'   Print Initiate Investigate Validate Audit Implement Summary Page in sigle report
    
    Dim arrSheets
    Dim arrAreas
    Dim i As Integer
            
    arrSheets = Array("Initiate", "Investigate", "Validate", "Audit", "Implement")
    arrAreas = Array("Print_Initiate", "Print_Investigate", "Print_Validate", "Print_Audit", "Print_Implement")
    
    For i = 0 To UBound(arrSheets)

    With Sheets(arrSheets(i)).PageSetup
        .PrintArea = arrAreas(i)
        .Zoom = False
        .FitToPagesWide = 1
        .FitToPagesTall = 2
        .Orientation = xlLandscape
        .BlackAndWhite = False
    
    arrAreas(i).PrintOut
    
    End With
    Next
    
End Sub

Cheers Paul :)
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Der.... worked it out
Ranges were not set correctly
Code:
Sub PrintAllDataSheets()
'   Print Initiate Investigate Validate Audit Implement Summary Page in sigle report
    
    Dim arrSheets
    Dim arrAreas
    Dim i As Integer
    
    arrSheets = Array("Initiate", "Investigate", "Validate", "Audit", "Implement")
    arrAreas = Array(Range("Print_Initiate"), Range("Print_Investigate"), Range("Print_Validate"), Range("Print_Audit"), Range("Print_Implement"))
    
    For i = 0 To UBound(arrSheets)
    Sheets(arrSheets(i)).PageSetup.PrintArea = arrAreas(i)

    arrAreas(i).PrintOut
    Next
    
End Sub

Wasted 2hours of my life on this, that I wont get back...... grrrr
 
Upvote 0

Forum statistics

Threads
1,214,976
Messages
6,122,539
Members
449,088
Latest member
RandomExceller01

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