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!
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
18,327
Office Version
2013
Platform
Windows
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
 

ndiaye

New Member
Joined
Sep 25, 2018
Messages
10
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
 

ndiaye

New Member
Joined
Sep 25, 2018
Messages
10
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.
 

ndiaye

New Member
Joined
Sep 25, 2018
Messages
10
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.
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
18,327
Office Version
2013
Platform
Windows
Ok, glad you got it sorted ...(y)
 

Forum statistics

Threads
1,086,205
Messages
5,388,408
Members
402,117
Latest member
Chaskon

Some videos you may like

This Week's Hot Topics

Top