How to sort worksheets in alphabetical / alphanumeric order in Excel?
Normally you can sort or arrange worksheet tabs order in Excel by dragging and dropping the sheet tabs on the sheet tab bar. But for getting this done with multiple worksheets, you may consider the following tricky ways to quickly sort worksheets in alphabetical / alphanumeric order in a large workbook.
Sort worksheets in alphabetical / alphanumeric order with VBA code
There is a macro for sorting worksheets by alpha posted in the Microsoft Support center. We can apply it with following steps:
1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and then paste the following macro in the Module Window.
VBA: Sort sheets in alphabetical / alphanumeric order
Dim xResult As VbMsgBoxResult
xTitleId = "KutoolsforExcel"
xResult = MsgBox("Sort Sheets in Ascending Order?" & Chr(10) & "Clicking No will sort in Descending Order", vbYesNoCancel + vbQuestion + vbDefaultButton1, xTitleId)
For i = 1 To Application.Sheets.Count
For j = 1 To Application.Sheets.Count - 1
If xResult = vbYes Then
If UCase$(Application.Sheets(j).Name) > UCase$(Application.Sheets(j + 1).Name) Then
Sheets(j).Move after:=Sheets(j + 1)
ElseIf xResult = vbNo Then
If UCase$(Application.Sheets(j).Name) < UCase$(Application.Sheets(j + 1).Name) Then
Application.Sheets(j).Move after:=Application.Sheets(j + 1)
3. Press the F5 key to run this macro. In the following prompt box, click Yes, all the worksheets will be sorted by ascending alphabetical order; and click No, all the worksheets will be sorted by descending alphabetical order.
Sort worksheets in alphabetical / alphanumeric order with Kutools for Excel
If you are not familiar with macros or prefer to other ways, you can try Kutools for Excel. Kutools for Excel's Sort Sheets tool can sort all worksheets easily.
1. Click Kutools Plus > Worksheet > Sort Sheets. See screenshot:
2. In the Sort Sheets dialog box, select one sorting type that you need on the right pane, such as Alpha Sort, Alpha Numeric Sort, and then click the OK button. See screenshot:
Then all worksheets are sorted based on the specified sorting type. See screenshot:
Kutools for Excel's Sort Sheets tool can quickly rearrange all worksheets in the active workbook. It supports several sorting types, including Alpha Sort, Alpha Numeric Sort, Color Sort and Reverse. In addition, you can also move up / down worksheets, and reset the sorting.
If you want to have a free trial ( 30-day) of this utility, please click to download it, and then go to apply the operation according above steps.
Demo: Sort all worksheets in alphabetical / alphanumeric order
Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
More than 300 powerful features. Supports Office/Excel
2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features
30-day free trial. 60-day money back guarantee.
Hi Imd, Do you mean all your sheet names are numbers and want to sort them ascending or descending? You can try the below VBA.
Dim i As Integer, j As Integer
For i = 1 To Sheets.Count
For j = 1 To Sheets.Count - 1
If Val(Replace(UCase(Sheets(j).Name), "SHEET", "")) > Val(Replace(UCase(Sheets(j + 1).Name), "SHEET", "")) Then Sheets(j).Move After:=Sheets(j + 1)
Good morning, On an Excel spread sheet, you can group columns of data. They condense and are represented by a + sign; if you want to expand them, a line appears along with the - sign. Can you perform a similar task with worksheets inside of an Excel workbook. I would like to condense a set of worksheets of a particular fiscal quarter. Please help, Terri
[b]Omg, such a time saver! [/b] I have a list to keep track of which books I've read by favorite serial-writer authors. A different worksheet for each author got plugged-in very haphazardly as I discovered new authors differentiating them only by tab colors. Over the years it has grown to [b]37 worksheets[/b]. For some reason it just occurred to me today that it would be darn nice to have them in alphabetical order. A task which seemed daunting when I thought of pushing them around by hand. I have an old 2003 vs of Excel, running in Windows 10. Also, I'm no Tech, I'm completely autodidactic, so attempting anything of this sort (for me) is always risky. Amazingly, it worked like a charm. THANK YOU, so much!
This macro worked great for me for a while! I have been using it in a huge spreadsheet at work, and it has been great for keeping it organized as I am continually adding new tabs. However, today I got this error message:
"Excel was able to open the file by repairing or removing the unreadable content. Removed Part: /xl/vbaProject.bin part. (Visual Basic for Applications (VBA))"
Now the macro is gone. Does anyone know why this happened or how I can fix it? I'd like to be able to keep using this macro without issues...
How can I force an alpha sort in which lower case follows upper case? I tried a Custom List, which accomplished nothing, realized I hadn't selected Options >> Case Sensitive and tried again, with almost the same results. Only difference was that Excel sorted individual lower case entries before identical upper case ones. What I want is: ABCDE ... WXYZabcde ... wxyz
Hi, I'm trying to run the macro but keep getting the error as follows:
expected end of statement.
The Macro is as follows: ysg2y VBA: Sort sheets order.
12345678910111213141516171819 Sub SortWorkBook() 'Updateby20140624 Dim xResult As VbMsgBoxResult xTitleId = "KutoolsforExcel"xResult = MsgBox("Sort Sheets in Ascending Order?" & Chr(10) & "Clicking No will sort in Descending Order", vbYesNoCancel + vbQuestion + vbDefaultButton1, xTitleId) For i = 1 To Application.Sheets.Count For j = 1 To Application.Sheets.Count - 1 If xResult = vbYes ThenIf UCase$(Application.Sheets(j).Name) > UCase$(Application.Sheets(j + 1).Name) ThenSheets(j).Move after:=Sheets(j + 1) End IfElseIf xResult = vbNo ThenIf UCase$(Application.Sheets(j).Name) < UCase$(Application.Sheets(j + 1).Name) ThenApplication.Sheets(j).Move after:=Application.Sheets(j + 1) End IfEnd IfNextNextEnd Sub