G
GEdwards
Using a macro I need to view specific worksheets if they have content. I
will always want my "Invoice" sheet and if on the Invoice sheet, cell B12 has
a value I want to view the Invoice and Labour sheet. If cell B13 has a value
I also want to view the Materials sheet.
My macro, shown below, halts at the line "Sheets(Array(prtWhat)).Select".
How can I dynamically build the proper statement...
"Sheets(Array("Invoice", "Labour", "Materials")).Select"
Please help.
Sub ViewTest()
prtWhat = "Invoice"
Labour = ", Labour"
Materials = ", Materials"
If Range("B12").Value <> "" Then
prtWhat = prtWhat & Labour
Else
prtWhat = prtWhat
End If
If Range("B13").Value <> "" Then
prtWhat = prtWhat & Materials
Else
prtWhat = prtWhat
End If
MsgBox (prtWhat)
Sheets(Array(prtWhat)).Select
Sheets("Invoice").Activate
ActiveWindow.SelectedSheets.PrintPreview
Sheets("Invoice").Select
End Sub
will always want my "Invoice" sheet and if on the Invoice sheet, cell B12 has
a value I want to view the Invoice and Labour sheet. If cell B13 has a value
I also want to view the Materials sheet.
My macro, shown below, halts at the line "Sheets(Array(prtWhat)).Select".
How can I dynamically build the proper statement...
"Sheets(Array("Invoice", "Labour", "Materials")).Select"
Please help.
Sub ViewTest()
prtWhat = "Invoice"
Labour = ", Labour"
Materials = ", Materials"
If Range("B12").Value <> "" Then
prtWhat = prtWhat & Labour
Else
prtWhat = prtWhat
End If
If Range("B13").Value <> "" Then
prtWhat = prtWhat & Materials
Else
prtWhat = prtWhat
End If
MsgBox (prtWhat)
Sheets(Array(prtWhat)).Select
Sheets("Invoice").Activate
ActiveWindow.SelectedSheets.PrintPreview
Sheets("Invoice").Select
End Sub