Need a VBA Code for select multiple sheets on excel

ndiaye

New Member
Joined
Sep 25, 2018
Messages
10
Hi, I am new user. And i need help.

I need a multiple selection VBA code for my work.

For example:

SheetX
SheetY
SheetZ
SheetA

I only need to select: SheetX and SheetZ. How should i write VBA Code for this?

I have nearly 450 sheets and will wrote the code for them.

Thanks a lot and have a good day to all from Istanbul, Turkey!
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
This will select by Sheet name


Code:
Sub MM1()
 Sheets("Sheet X").Select
 Sheets("Sheet Z").Select (False)
End Sub

And this one by Sheet number

Code:
Sub MM2()
 Sheets(1).Select
 Sheets(3).Select (False)
End Sub
 
Upvote 0
Hi again,

One of the excel sheet name is including "ş","ğ" etc.

What should i do? It brings the values as "?"

What am i gonna do? Btw thanks for first rep.

This will select by Sheet name


Code:
Sub MM1()
 Sheets("Sheet X").Select
 Sheets("Sheet Z").Select (False)
End Sub

And this one by Sheet number

Code:
Sub MM2()
 Sheets(1).Select
 Sheets(3).Select (False)
End Sub
 
Upvote 0
Once again,

I tried with sheetname method and received an error - I wrote the problem the previouse time.

I tried the to select the sheet with their index names but it says

run time error 1004
select method of worksheet class failed

I searched it a little could not find smtg useful.

Hi again,

One of the excel sheet name is including "ş","ğ" etc.

What should i do? It brings the values as "?"

What am i gonna do? Btw thanks for first rep.
 
Upvote 0
I Solved this myself.

The problem is there must be a hide'd sheets!

When i run it again - using the method sheet index - it worked!

Thanks for replier and the viewers and also me! :)

Once again,

I tried with sheetname method and received an error - I wrote the problem the previouse time.

I tried the to select the sheet with their index names but it says

run time error 1004
select method of worksheet class failed

I searched it a little could not find smtg useful.
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,184
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top