ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Select first 3 sheets (https://www.excelbanter.com/excel-programming/349197-select-first-3-sheets.html)

StephanieH

Select first 3 sheets
 
I need to select the first 3 sheets in my workbook, regardless of their
names. I've tried
Sheets(Array(Sheets(1), Sheets(2), Sheets(3))).Select
but I get "Type Mismatch"

What am I doing wrong?


Norman Jones

Select first 3 sheets
 
Hi StephanieH,

Try:

Sheets(Array(1, 2, 3)).Select

---
Regards,
Norman



"StephanieH" wrote in message
...
I need to select the first 3 sheets in my workbook, regardless of their
names. I've tried
Sheets(Array(Sheets(1), Sheets(2), Sheets(3))).Select
but I get "Type Mismatch"

What am I doing wrong?




Tom Ogilvy

Select first 3 sheets
 
Sheets(Array(1,2,3)).Select

--
Regards,
Tom Ogilvy


"StephanieH" wrote in message
...
I need to select the first 3 sheets in my workbook, regardless of their
names. I've tried
Sheets(Array(Sheets(1), Sheets(2), Sheets(3))).Select
but I get "Type Mismatch"

What am I doing wrong?




Doug Glancy

Select first 3 sheets
 
Stephanie,

The mismatch is because it's looking for strings (sheet names):

Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select

hth,

Doug


"StephanieH" wrote in message
...
I need to select the first 3 sheets in my workbook, regardless of their
names. I've tried
Sheets(Array(Sheets(1), Sheets(2), Sheets(3))).Select
but I get "Type Mismatch"

What am I doing wrong?




StephanieH

Select first 3 sheets
 
Perfect. Thanks Norman and Tom.

Doug, I think you've specified "Sheet1" as the sheet name, which is what I'm
avoiding.



"StephanieH" wrote:

I need to select the first 3 sheets in my workbook, regardless of their
names. I've tried
Sheets(Array(Sheets(1), Sheets(2), Sheets(3))).Select
but I get "Type Mismatch"

What am I doing wrong?


Doug Glancy

Select first 3 sheets
 
Yes, my mistake.

Doug


"StephanieH" wrote in message
...
Perfect. Thanks Norman and Tom.

Doug, I think you've specified "Sheet1" as the sheet name, which is what
I'm
avoiding.



"StephanieH" wrote:

I need to select the first 3 sheets in my workbook, regardless of their
names. I've tried
Sheets(Array(Sheets(1), Sheets(2), Sheets(3))).Select
but I get "Type Mismatch"

What am I doing wrong?





All times are GMT +1. The time now is 10:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com