stormseeker75
New Member
- Joined
- Mar 19, 2025
- Messages
- 21
- Office Version
- 365
- Platform
- Windows
Hello! I've tried everything here and I hope you folks can help me. I have a spreadsheet with several tabs. On each tab, I've defined a named range for the tab. For example, on my Sales Sheet tab, I have the named range called SALES_SHEET. I also have Additional Pages-1 through -8. Sometimes these have data and sometimes they don't.
I have another sheet in my workbook that contains a variable driven by each sheet in my tab, 1 or 0 based on a cell value on the corresponding worksheet. For example, when Additional Pages-4 has a value in a particular cell, it sets my table to show a 1. If there was no value, it would show a 0.
Here's what we are currently up to:
What I'd like to be able to do is have VBA look at my list and if it has a 1, print the appropriate named range. If it has a 0, move on along to the next one and don't error out.
As an added bonus, I'd like this entire document to be printed as a PDF. I can make things print out to PDF when needed, but I can't make the whole thing dance.
I have another sheet in my workbook that contains a variable driven by each sheet in my tab, 1 or 0 based on a cell value on the corresponding worksheet. For example, when Additional Pages-4 has a value in a particular cell, it sets my table to show a 1. If there was no value, it would show a 0.
Here's what we are currently up to:
VBA Code:
Sub TEST_PRINT()
On Error Resume Next
Application.Dialogs(xlDialogPrinterSetup).Show
Sheets("DO NOT DELETE").Select ' <<<<---Page where data is
If Range("Z2").Value = 1 Then
Sheets("Main Page").PrintOut
ElseIf Range("Z3").Value = 1 Then
Sheets("Additional Page-1").PrintOut
ElseIf Range("Z4").Value = 1 Then
Sheets("Additional Page-2").PrintOut
ElseIf Range("Z5").Value = 1 Then
Sheets("Additional Page-3").PrintOut
ElseIf Range("Z6").Value = 1 Then
Sheets("Additional Page-4").PrintOut
ElseIf Range("Z7").Value = 1 Then
Sheets("Additional Page-5").PrintOut
ElseIf Range("Z8").Value = 1 Then
Sheets("Additional Page-6").PrintOut
ElseIf Range("Z9").Value = 1 Then
Sheets("Additional Page-7").PrintOut
ElseIf Range("Z10").Value = 1 Then
Sheets("Additional Page-8").PrintOut
ElseIf Range("Z11").Value = 1 Then
Sheets("Maintenance Check List").PrintOut
ElseIf Range("Z12").Value = 1 Then
Sheets("Chassis Inspection").PrintOut
ElseIf Range("Z13").Value = 1 Then
Sheets("Estimate").PrintOut
ElseIf Range("Z14").Value = 1 Then
Sheets("Sales Sheet").PrintOut
End If
End Sub
What I'd like to be able to do is have VBA look at my list and if it has a 1, print the appropriate named range. If it has a 0, move on along to the next one and don't error out.
As an added bonus, I'd like this entire document to be printed as a PDF. I can make things print out to PDF when needed, but I can't make the whole thing dance.