跳到主要內容

如何在Excel中按字母/字母數字順序對工作表進行排序?

通常,您可以通過在工作表標籤欄上拖放工作表標籤來在Excel中對工作表標籤進行排序或排列。 但是,要使用多個工作表完成此工作,您可以考慮以下棘手的方法,以便在大型工作簿中按字母/字母數字順序快速對工作表進行排序。

使用VBA代碼按字母/字母數字順序對工作表進行排序
使用Kutools for Excel按字母/字母數字順序對工作表進行排序


使用VBA代碼按字母/字母數字順序對工作表進行排序

Microsoft支持中心中有一個用於按字母排序工作表的宏。 我們可以通過以下步驟應用它:

1.  按住 ALT + F11 鍵,然後打開 Microsoft Visual Basic for Applications 窗口。

2.  點擊 插入 > 模塊,然後將以下宏粘貼到 模塊窗口.

VBA:按字母/字母數字順序對工作表進行排序

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 Then
            If UCase$(Application.Sheets(j).Name) > UCase$(Application.Sheets(j + 1).Name) Then
                Sheets(j).Move after:=Sheets(j + 1)
            End If
            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)
            End If
        End If
    Next
Next
End Sub

3。 按 F5 運行此宏的鍵。 在以下提示框中,單擊 ,所有工作表將按字母升序排序; 然後點擊 沒有,所有工作表將按字母降序排序。


使用Kutools for Excel按字母/字母數字順序對工作表進行排序

如果您不熟悉宏或喜歡其他方式,可以嘗試 Excel的Kutools. Excel的Kutools's 排序表 工具可以輕鬆地對所有工作表進行排序。

申請前 Excel的Kutools首先下載並安裝.

1。 點擊 Kutools 加 > 下載學習單 > 排序表。 看截圖:

2。 在 排序表 對話框中,在右側窗格中選擇所需的一種排序類型,例如 字母排序, 字母數字排序,然後單擊 OK 按鈕。 看截圖:

然後,根據指定的排序類型對所有工作表進行排序。 看截圖:

文檔排序表6

Excel的Kutools's 排序表 工具可以快速重新排列活動工作簿中的所有工作表。 它支持多種排序類型,包括 字母排序, 字母數字排序, 顏色分類逆轉。 此外,您還可以在工作表中上/下移動並重置排序。

  如果您想免費試用(30天)此實用程序, 請點擊下載,然後按照上述步驟進行操作。


演示:按字母/字母數字順序對所有工作表進行排序


相關文章:

按顏色對工作表標籤進行排序

最佳辦公生產力工具

🤖 Kutools 人工智慧助手:基於以下內容徹底改變數據分析: 智慧執行   |  生成代碼  |  建立自訂公式  |  分析數據並產生圖表  |  呼叫 Kutools 函數...
熱門特色: 尋找、突出顯示或識別重複項   |  刪除空白行   |  合併列或儲存格而不遺失數據   |   沒有公式的回合 ...
超級查詢: 多條件VLookup    多值VLookup  |   跨多個工作表的 VLookup   |   模糊查詢 ....
高級下拉列表: 快速建立下拉列表   |  依賴下拉列表   |  多選下拉列表 ....
欄目經理: 新增特定數量的列  |  移動列  |  切換隱藏列的可見性狀態  |  比較範圍和列 ...
特色功能: 網格焦點   |  設計圖   |   大方程式酒吧    工作簿和工作表管理器   |  資源庫 (自動文字)   |  日期選擇器   |  合併工作表   |  加密/解密單元格    按清單發送電子郵件   |  超級濾鏡   |   特殊過濾器 (過濾粗體/斜體/刪除線...)...
前 15 個工具集12 文本 工具 (添加文本, 刪除字符,...)   |   50+ 圖表 類型 (甘特圖,...)   |   40+ 實用 公式 (根據生日計算年齡,...)   |   19 插入 工具 (插入二維碼, 從路徑插入圖片,...)   |   12 轉化 工具 (數字到單詞, 貨幣兌換,...)   |   7 合併與拆分 工具 (高級合併行, 分裂細胞,...)   |   ... 和更多

使用 Kutools for Excel 增強您的 Excel 技能,體驗前所未有的效率。 Kutools for Excel 提供了 300 多種進階功能來提高生產力並節省時間。  點擊此處獲取您最需要的功能...

產品描述


Office選項卡為Office帶來了選項卡式界面,使您的工作更加輕鬆

  • 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,發布者,Access,Visio和Project。
  • 在同一窗口的新選項卡中而不是在新窗口中打開並創建多個文檔。
  • 將您的工作效率提高 50%,每天為您減少數百次鼠標點擊!

Comments (81)
Rated 5 out of 5 · 2 ratings
This comment was minimized by the moderator on the site
Grazie, ha funzionato perfettamente e mi ha risparmiato un sacco di lavoro. Complimenti
Rated 5 out of 5
This comment was minimized by the moderator on the site
Bom dia a macro funcionou porém com uma falha, veja no exemplo:
Abas (ANEXO 1, ANEXO 10, ANEXO 100, ANEXO 2, ANEXO 20)
Em uma planilha com os anexos acima ele organiza exatamente como está acima
Ele respeita a ordem somente a cada 10

Alguém sabe como corrigir? Olhei no font da macro mas não encontrei o problema
This comment was minimized by the moderator on the site
Macro qui marche parfaitement, en 30s c'est fait. Merci beaucoup
Rated 5 out of 5
This comment was minimized by the moderator on the site
Does anyone know how I would negate text from this macro? for example if my sheets were named "cafe 1st floor" and "kitchen 2nd floor" but id like to get rid of "cafe" and "kitchen"
thank you!
This comment was minimized by the moderator on the site
not working if your sheet was number ex: 1, 2, 10 12,
after sort: 1, 10, 12, 2
This comment was minimized by the moderator on the site
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.

Sub Test1()

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)

Next j

Next i

End Sub
This comment was minimized by the moderator on the site
Thank you for the macro !!!
This comment was minimized by the moderator on the site
Thank you for your help, very much appreciated...
This comment was minimized by the moderator on the site
I don't know VBA at all but your instructions worked perfectly. Thank you so much!
This comment was minimized by the moderator on the site
Thank you :)
This comment was minimized by the moderator on the site
Very helpful :) Thank you!
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations