Subscript out of range

thewiseguy

Well-known Member
Joined
May 23, 2005
Messages
954
Office Version
  1. 365
Platform
  1. Windows
Can someone tell me what this means:

Sub Print_to_PDF_Installer_Docs()
'
' Print_to_PDF Macro
'

'
Sheets(Array("Project Detail (install)", "Checklist (Install)", "BOM (Install)", "LxL (Install)", "DamagedFixture (Install)", "RecycleRequest (Install)", "Labor Budget (Install)")).Select
Sheets("Project Detail (install)").Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
End Sub
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
It's almost self-explanatory.

A group of sheets is selected, and one of these is made the active sheet.
One copy of each selected sheet is printed (to the default printer) as a collated document, using each sheet's defined print area.
 
Upvote 0
It's almost self-explanatory.

A group of sheets is selected, and one of these is made the active sheet.
One copy of each selected sheet is printed (to the default printer) as a collated document, using each sheet's defined print area.
sorry i should have been more clear. why am I getting a "subscript out of range" error? Im new to VBA.

thanks
 
Upvote 0
sorry i should have been more clear. why am I getting a "subscript out of range" error? Im new to VBA.

thanks
More than likely it is trying to select a sheet name that doesn't exist. I would double check all your sheet names spelling in the code and make sure they are accurate.
 
Upvote 0
More than likely it is trying to select a sheet name that doesn't exist. I would double check all your sheet names spelling in the code and make sure they are accurate.

any other ideas? i just changed each sheet name to have no spaces then amedned the code and still getting the error
 
Upvote 0
any other ideas? i just changed each sheet name to have no spaces then amedned the code and still getting the error
Nope. Maybe post a screen shot with all your sheet names and the code exactly as it is now so we can look at it.
 
Upvote 0
Nope. Maybe post a screen shot with all your sheet names and the code exactly as it is now so we can look at it.

Sub Print_to_PDF_Installer_Docs()
'
' Print_to_PDF Macro
'

'
Sheets(Array("ProjectDetail(install)", "Checklist(Install)", "BOM(Install)", "LxL(Install)", "DamagedFixture(Install)", "RecycleRequest(Install)", "LaborBudget(Install)")).Select
Sheets("ProjectDetail(install)").Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
End Sub


worksheet_Names.png
 
Upvote 0
"ProjectDetail(Install)" may be different from "ProjectDetail(install)", though a quick test shows it should still work.

One by one, test each sheet name in the Immediate Window:

VBA Code:
Worksheets(actual_sheet_name).Activate

And I might be showing my OCD here, I always say Worksheets and not Sheets. Always be as specific as possible in VBA. (Also, Worksheets has IntelliSense and Sheets does not.)
 
Upvote 0
Sub Print_to_PDF_Installer_Docs()
'
' Print_to_PDF Macro
'

'
Sheets(Array("ProjectDetail(install)", "Checklist(Install)", "BOM(Install)", "LxL(Install)", "DamagedFixture(Install)", "RecycleRequest(Install)", "LaborBudget(Install)")).Select
Sheets("ProjectDetail(install)").Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
End Sub


View attachment 100749
You have an extra ")" on sheet name "BOM(Install))".
 
Upvote 0

Forum statistics

Threads
1,215,093
Messages
6,123,067
Members
449,090
Latest member
fragment

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