EXCEL按SHEET排序

2/23/2009来源:Excel教程人气:13272

再任意一个工作表名称点右键,点查看源代码,把下面代码复制过去执行
Sub Sort_Sheets()
Dim sCount As Integer, I As Integer, R As Integer
ReDim Na(0) As String
sCount = Sheets.Count
For I = 1 To sCount
ReDim PReserve Na(I) As String
Na(I) = Sheets(I).Name
Next
For I = 1 To sCount - 1
For R = I + 1 To sCount
If Na(R) < Na(I) Then
JH = Na(I)
Na(I) = Na(R)
Na(R) = JH
End If
Next
Next
For I = 1 To sCount
Sheets(Na(I)).Move After:=Sheets(I)
Next
End Sub

Excel 根据sheet名排序
随便点一个sheet,查看代码Sub 按字母排序工作表()If MsgBox("真的要按工作表名称首字拼音的顺序(A~Z)来排序工作表吗?", vbYesNo, "请确认此次替换") = vbYes ThenDim wbook As Workbook, wsheet As Worksheet, i As Integer, countsh As Integer, ss() As StringSet wbook = ActiveWorkbook
countsh = wbook.Sheets.Count
ReDim ss(1 To countsh)
For i = 1 To countsh
ss(i) = wbook.Sheets(i).Name
Next
Set wsheet = wbook.Worksheets.Add
For i = 1 To countsh
wsheet.Cells(i, 1).Value = ss(i)
Next
wsheet.Columns(1).Sort Key1:=wsheet.Columns(1), Order1:=xlAscending
For i = 1 To countsh
ss(i) = wsheet.Cells(i, 1).Value
Next
application.DisplayAlerts = False
wsheet.Delete
Application.DisplayAlerts = True
For i = 1 To countsh
wbook.Sheets(ss(i)).Move after:=wbook.Sheets(countsh)
NextElse: MsgBox "用户取消了此次排序操作!"
End If
End Sub执行搞定,^_^

还有个Word里的,硬回车替换软回车^l替换^p