LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default ARRAYS

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 ?

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Avg Arrays PAL Excel Worksheet Functions 2 February 13th 09 06:02 PM
Use of IF with arrays Andrew L Excel Worksheet Functions 5 August 15th 08 10:15 PM
Use of arrays DKS Excel Worksheet Functions 1 November 30th 06 08:38 PM
Use of arrays Dave F Excel Worksheet Functions 0 November 30th 06 04:26 PM
Use of arrays DKS Excel Worksheet Functions 0 November 30th 06 04:11 PM


All times are GMT +1. The time now is 08:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"