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
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
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:
Upvote 0

Forum statistics

Threads
1,215,022
Messages
6,122,726
Members
449,093
Latest member
Mnur

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