excel VBA按字母表顺序对工作表进行排序
时间:2023-08-23 10:19:24
如果工作簿内有大量以字母开头的工作表,要将这些工作表按照字母表的顺序进行排序,可以用下面的VBA代码来实现。按Alt+F11,打开VBA编辑器,单击菜单“插入→模块”,在代码窗口中粘贴下列代码并执行。
Sub 按字母表排序工作表()
Dim i As Integer, j As Integer, n As Integer
On Error Resume Next
n = Sheets.Count
If n = 1 Then End
For i = 1 To n – 1
For j = i + 1 To n
If UCase(Sheets(j).Name) < UCase(Sheets(i).Name) Then
Sheets(j).Move Before:=Sheets(i)
End If
Next j
Next i
End Sub
上述代码是按照字母表升序来对工作表进行排序的,如果要按降序排序,将代码中的小于号改为大于号即可。
标签:代码,字母表,工作,排序,Excel函数
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
MAC休眠后黑屏几秒钟才恢复该怎么办?
2022-10-07 09:58:39
![](https://img.aspxhome.com/file/2023/9/a216479_0s.jpg)
怎么将Word中的内容插入到Excel
2022-04-18 10:56:38
![](https://img.aspxhome.com/file/2023/7/a167527_0s.jpg)
excel表格怎样设置将内容分开
2022-07-02 02:27:46
win10系统字体文件删除不了提示在system中打开无法删除的解决方法图文教程
2023-05-16 05:28:08
![](https://img.aspxhome.com/file/2023/28/a242507_0s.jpg)
Word怎么添加条形码 word文档添加条形码教程
2022-04-11 07:39:12
![](https://img.aspxhome.com/file/2023/1/24491_0s.png)
Win11分屏要怎么设置?Win11分屏设置的操作方法
2022-07-31 06:56:06
![](https://img.aspxhome.com/file/2023/2/a284112_0s.png)
升级Win8.1系统点击文件Setup.exe提示不支持此升级路径
2022-04-15 07:12:46
![](https://img.aspxhome.com/file/2023/3/a301584_0s.jpg)
深度技术教你解决Win XP无法访问Windows7文件
2023-07-07 20:19:25
win10声音怎么增强?Win10声音太小增强音质的详细方法
2022-07-18 11:20:18
![](https://img.aspxhome.com/file/2023/5/52075_0s.jpg)
Win7系统后预览窗口不显示如何解决
2023-01-22 06:22:15
![](https://img.aspxhome.com/file/2023/3/a293434_0s.jpg)
Excel中,怎样批量删除单位
2023-09-07 21:26:45
win7/win8.1/win10系统下如何配置Java环境变量 Java环境变量的配置教程介绍
2023-01-13 07:31:15
![](https://img.aspxhome.com/file/2023/28/a246309_0s.jpg)
iphone如何打开美颜进行微信视频通话 苹果手机微信打开美颜进行视频通话的教程
2022-04-13 13:46:13
![](https://img.aspxhome.com/file/2023/8/a335930_0s.jpg)
Win7系统360安全卫士打不开也无法卸载的解决方法
2023-12-30 21:32:29
![](https://img.aspxhome.com/file/2023/3/a299259_0s.jpg)
ps怎么设计一款叠加心形图标?ps心形重叠效果的方法
2023-08-05 02:14:35
![](https://img.aspxhome.com/file/2023/1/a273440_0s.jpg)
boss直聘怎么删除对话?boss直聘删除对话的方法
2022-10-26 18:35:47
![](https://img.aspxhome.com/file/2023/8/a333110_0s.jpg)
Bandizip右键菜单不见了怎么办?
2022-04-28 02:58:59
如何在WPS文字运用公式计算
2023-05-10 07:15:15
![](https://img.aspxhome.com/file/2023/4/a186714_0s.jpg)
Acrotray.exe是什么进程?Acrotray.exe删除了有什么影响
2022-10-04 23:46:09
![](https://img.aspxhome.com/file/2023/6/a321115_0s.png)
Win10家庭版如何关闭自动更新?Win10家庭版关闭自动更新方法
2022-09-04 07:54:45
![](https://img.aspxhome.com/file/2023/26/a222104_0s.jpg)