Option Explicit
Sub sapxepSheet()
Application.ScreenUpdating = False
Dim count&, i&, j&, k&, name As String, arr()
count = Sheets.count
ReDim arr(1 To count, 1 To 2)
For i = 1 To count - 1
name = Sheets(i).name
' Doi ten sheet voi so km format dang "000" va luu tên cu lai
If name Like "KM*+*" Then
k = k + 1
arr(k, 1) = name
arr(k, 2) = "KM" & Format(Mid(name, 3, InStr(3, name, "+") - 3), "000") & Mid(name, InStr(3, name, "+"), 255)
Sheets(i).name = arr(k, 2)
End If
Next
'Sap xep tang dan
For i = 1 To count - 1
For j = i + 1 To count
If Sheets(j).name < Sheets(i).name Then
Sheets(j).Move before:=Sheets(i)
End If
Next j
Next i
'Tra lai ten cho em
For i = 1 To count
For j = 1 To UBound(arr)
If Sheets(i).name = arr(j, 2) Then Sheets(i).name = arr(j, 1)
Next
Next
Application.ScreenUpdating = True
End Sub