G
Gary B
Hi there,
Having a problem with the following code
Sub mcrPrint()
Dim prange As String
Sheets("macroinputs").Range("N1").Value = InputBox("Enter
Section No to print/preview or ALL", , "ALL")
Sheets("macroinputs").Range("N2").Value = InputBox("Print
(Y) or Preview (N)", , "N")
prange = Sheets("macroinputs").Range("O8").Value
If Sheets("macroinputs").Range("N1").Value <> "All"
Then
Sheets(Array(prange)).Select
If Sheets("macroinputs").Range("N2").Value = "Y"
Then
ActiveWindow.SelectedSheets.PrintOut
Copies:=1, Collate:=True
Else
ActiveWindow.SelectedSheets.PrintPreview
End If
End If
End Sub
I get an error "Subscript out of range" run-time error 9
What I am trying to do is as follows:-
The excle file has over 100 sheets, some of which are
hidden. Sheets are broken down into 10 sections, but
there may only be 4 sheets in a given section that
require printing.
I use a table to list which sheets are hidden, or not.
To get the value for prange - as in the code, I use a
lookup on this table.
The data in prange is currently
"CAT0", "00", "01", "06", "07", "08", "09"
as you can see, sheets "02", "03", "04", "05" are hidden,
and do not require printing.
When I replace prange in the vb code, with this value,
the macro works just fine.
What can I do ?
Having a problem with the following code
Sub mcrPrint()
Dim prange As String
Sheets("macroinputs").Range("N1").Value = InputBox("Enter
Section No to print/preview or ALL", , "ALL")
Sheets("macroinputs").Range("N2").Value = InputBox("Print
(Y) or Preview (N)", , "N")
prange = Sheets("macroinputs").Range("O8").Value
If Sheets("macroinputs").Range("N1").Value <> "All"
Then
Sheets(Array(prange)).Select
If Sheets("macroinputs").Range("N2").Value = "Y"
Then
ActiveWindow.SelectedSheets.PrintOut
Copies:=1, Collate:=True
Else
ActiveWindow.SelectedSheets.PrintPreview
End If
End If
End Sub
I get an error "Subscript out of range" run-time error 9
What I am trying to do is as follows:-
The excle file has over 100 sheets, some of which are
hidden. Sheets are broken down into 10 sections, but
there may only be 4 sheets in a given section that
require printing.
I use a table to list which sheets are hidden, or not.
To get the value for prange - as in the code, I use a
lookup on this table.
The data in prange is currently
"CAT0", "00", "01", "06", "07", "08", "09"
as you can see, sheets "02", "03", "04", "05" are hidden,
and do not require printing.
When I replace prange in the vb code, with this value,
the macro works just fine.
What can I do ?