批量将EXCEL的SHEET放到一起并排序
1
2
3、Sub 按A列数据修改表名称()
On Error Resume Next '忽略错误继续执行VBA代码,避免出现错误消息
Application.Calculation = xlCalculationManual '手动重算
Dim i%
For i = 1 To Sheets.Count
Sheets(i).Name = Cells(i, 1).Text
Next
On Error GoTo 0 '恢复正常的错误提示
Application.Calculation = xlCalculationAutomatic '自动重算
End Sub
4
5
6、Sub 按A列数据修改表名称()
On Error Resume Next '忽略错误继续执行VBA代码,避免出现错误消息
Application.Calculation = xlCalculationManual '手动重算
Dim i%
For i = 1 To Sheets.Count
Sheets(i).Name = Cells(i, 1).Text
Next
On Error GoTo 0 '恢复正常的错误提示
Application.Calculation = xlCalculationAutomatic '自动重算
End Sub
7
8
9、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