Sort Excel Worksheets Based on Second Letter In Name

JimHol

Active Member
Joined
Jan 4, 2011
Messages
314
Is it possible to have a macro that will sort all of the worksheets in my workbook by the second character in the sheet name only is the first character is a number. If the first character is not a number it would sort using the first character.

Thanks,
Jim
 

Some videos you may like

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

BigC

Well-known Member
Joined
Aug 4, 2002
Messages
851
Check out the list of 585 Excel articles on this site (goto home page and then scroll down to the very bottom to the General section to find the page link http://www.mrexcel.com/articles.shtml
In the VBA section there is a link (http://www.cpearson.com/excel/sortws.aspx)
to an article by Chip Pearson about sorting worksheets by name, etc. from which I expect you can adapt the code to suit your situation.

You may need additional code to create and populate an array with "trimmed" sheet names to use as the basis for the sorting. These will be derived by using an If x Then y test to identify which sheet names have numbers as 1st characters that need to be dropped using a string method, and which don't)
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,123,382
Messages
5,601,309
Members
414,441
Latest member
KellyTheKid

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
Top