For j = i + 1 To sCount
If Worksheets(j).Name < Worksheets(i).Name Then Worksheets(j).Move Before:=Worksheets(i) End If Next j Next i End Sub
示例说明:若想排序所有工作表,将代码中的Worksheets替换为Sheets。
[示例04-18]删除当前工作簿中的空工作表 Sub Delete_EmptySheets() Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
If Application.WorksheetFunction.CountA(sh.Cells) = 0 Then Application.DisplayAlerts = False sh.Delete
Application.DisplayAlerts = True End If Next End Sub