跳到主要内容

如何在Excel中按字母/字母数字顺序对工作表进行排序?

通常,您可以通过在工作表标签栏上拖放工作表标签来在Excel中对工作表标签进行排序或安排。 但是,要使用多个工作表完成此工作,您可以考虑以下棘手的方法,以便在大型工作簿中按字母/字母数字顺序快速对工作表进行排序。

使用VBA代码按字母/字母数字顺序对工作表进行排序
使用 Kutools for Excel 按字母/字母数字顺序对工作表进行排序


使用VBA代码按字母/字母数字顺序对工作表进行排序

Microsoft支持中心中有一个用于按字母排序工作表的宏。 我们可以通过以下步骤应用它:

1.  按住 ALT + F11 键,然后打开 Microsoft Visual Basic应用程序 窗口。

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 按字母/字母数字顺序对工作表进行排序

如果您不熟悉宏或喜欢其他方式,可以尝试 Kutools for Excel. Kutools for Excel's 排序表 工具可以轻松地对所有工作表进行排序。

申请前 Kutools for Excel首先下载并安装.

1。 点击 Kutools 加 > 工作表 > 排序表。 看截图:

2。 在 排序表 对话框中,在右侧窗格中选择所需的一种排序类型,例如 字母排序, 字母数字排序,然后单击 OK 按钮。 看截图:

然后,根据指定的排序类型对所有工作表进行排序。 看截图:

文档排序表6

Kutools for Excel's 排序表 工具可以快速重新排列活动工作簿中的所有工作表。 它支持多种排序类型,包括 字母排序, 字母数字排序, 颜色分类逆转。 此外,您还可以在工作表中上/下移动并重置排序。

  如果您想免费试用(30天)此实用程序, 请点击下载,然后按照上述步骤进行操作。


演示:按字母/字母数字顺序对所有工作表进行排序


相关文章:

按颜色对工作表标签进行排序

最佳办公生产力工具

🤖 Kutools 人工智能助手:基于以下内容彻底改变数据分析: 智能执行   |  生成代码  |  创建自定义公式  |  分析数据并生成图表  |  调用 Kutools 函数...
热门特色: 查找、突出显示或识别重复项   |  删除空白行   |  合并列或单元格而不丢失数据   |   不使用公式进行四舍五入 ...
超级查询: 多条件VLookup    多值VLookup  |   跨多个工作表的 VLookup   |   模糊查询 ....
高级下拉列表: 快速创建下拉列表   |  依赖下拉列表   |  多选下拉列表 ....
列管理器: 添加特定数量的列  |  移动列  |  切换隐藏列的可见性状态  |  比较范围和列 ...
特色功能: 网格焦点   |  设计图   |   大方程式酒吧    工作簿和工作表管理器   |  资源库 (自动文本)   |  日期选择器   |  合并工作表   |  加密/解密单元格    按列表发送电子邮件   |  超级筛选   |   特殊过滤器 (过滤粗体/斜体/删除线...)...
前 15 个工具集12 文本 工具 (添加文本, 删除字符,...)   |   50+ 图表 类型 (甘特图,...)   |   40+ 实用 公式 (根据生日计算年龄,...)   |   19 插入 工具 (插入二维码, 从路径插入图片,...)   |   12 转化 工具 (小写金额转大写, 货币兑换,...)   |   7 合并与拆分 工具 (高级组合行, 分裂细胞,...)   |   ... 和更多

使用 Kutools for Excel 增强您的 Excel 技能,体验前所未有的效率。 Kutools for Excel 提供了 300 多种高级功能来提高生产力并节省时间。  单击此处获取您最需要的功能...

产品描述


Office Tab 为 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