Excel Macro to open Excel sheets in various sequences

Adreno

New Member
Joined
Jul 31, 2013
Messages
2
Hello, I am trying to make macros to unhide hidden sheets in different sequences then its original sequesces.

Example :

I have sheets Control Sheet,A,B,C,D,E,F,G & H

I want,
i) Button 1 to hide all sheets apart from Control sheet and then unhide and display in following sequence - C,E,A,B & F
ii) Button 2 to hide all sheets apart from Control sheet and then unhide and display in following sequence - A,B,H,G & C
iii) button 1 to hide all sheets apart from Control sheet and then unhide and display in following sequence - C,E,D,B,A& F

I have created macro but it doesnt display unhidden sheets in sequence I want but it displays in sequence original sheets had.

Please help !!!!!!!!!!!!!!!!!

Thank you
 

Some videos you may like

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Trevor G

Well-known Member
Joined
Jul 17, 2008
Messages
6,501
Welcome to the forum, Indicated below is the code that will sort worksheets into an order. You can adapt it so that it unhides or hides if they aren't being named.

Sub SortWorksheets3()
Dim SortOrder As Variant
Dim Ndx As Long
SortOrder = Array("First", "Middle", "Last")
For Ndx = UBound(SortOrder) To LBound(SortOrder) Step -1
Worksheets(SortOrder(Ndx)).Move before:=Worksheets(1)
Next Ndx
End Sub
 

Adreno

New Member
Joined
Jul 31, 2013
Messages
2
Hi Trevor,

Thank you for your reply. I am very new to Excel so will you be kind and use sheet names A,B,C,D,E,F as shown in my example in the macro you have suggested. It will help me to understand and implement it easily. Thanks and sorry for trouble.

- Adreno
 

Watch MrExcel Video

Forum statistics

Threads
1,099,771
Messages
5,470,690
Members
406,717
Latest member
Harsha Maskara

This Week's Hot Topics

Top