PDA

View Full Version : [SOLVED] Sorting Sheets in a specific order



Sandler
12-19-2016, 02:42 PM
First and foremost, I do have a post from this morning on MrExcel.com. However, I am changing my question.

Say I have tabs with the following numerical names and those tabs come in sorted in numerical order from a tool that runs report.
However, I want the tabs to be in a very specific order.

For example, say I have the following tabs: 1,2,3,4,5,6,7,8,9,10

But I need them in this specific order: 5,2,8,9,3,1,4,6,7,10

How can I instruct Excel to sort my tabs in that order.

It will be the same exact order every month, so I would rather have the tab names sorted in the VBA code rather than have VBA read the list from a spreadsheet and sort.

Thanks :)

p45cal
12-19-2016, 03:47 PM
For Each n In Array(5, 2, 8, 9, 3, 1, 4, 6, 7, 10)
Sheets(CStr(n)).Move after:=Sheets(Sheets.Count)
Next n

Sandler
12-19-2016, 04:35 PM
This my friend, is perfect :)

Thank You