1

I'm trying to make a selection of multiple sheets one workbook based on run macros. At the end I have string containing sheets for selection, but my program prompt errors ...

Example:

SheetPrintPDF=Split(SheetPrintPDFTemp, ",")  
Rem Debug show me that SheetPrintPDFTemp contains "Sheet1, Sheet17, Sheet24"  

Wb1.Sheets(Array(SheetPrintPDF)).Select  
Rem Program error "method class sheet error"

when I write ...

Wb1.Sheets(Array("Sheet1", "Sheet17", "Sheet24")).Select 

Select works fine.

1
  • 1
    Could the whitespace after the comma be causing it? Try splitting on ", " Commented Mar 9, 2015 at 16:05

2 Answers 2

1

The problem is that you don't need to label the array as an array in your desired code because it already is one. Try:

Wb1.Sheets(SheetPrintPDF).Select  
Sign up to request clarification or add additional context in comments.

2 Comments

This and Mat's Mug's comment together fixed it
Hi result is "Runtime error 9 : Subscript is out of range"
0

I solved by filling the values directly into the field into the FOR loop

Example. ArrayTemp(x) = SheetPrintPDFTemp

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.