When you have more than 10 worksheets in your excel file, it's very urgent to sort these sheets on the basis of their sheet name so that we can find them very easily.
VBA code for that is as follows:
Sub sortSheet()
Dim sheetcount, a, b As Integer
Application.ScreenUpdating = False
sheetcount = Worksheets.Count
If sheetcount = 1 Then Exit Sub
For a = 1 To sheetcount - 1
For b = a + 1 To sheetcount
If Worksheets(b).Name < Worksheets(a).Name Then
Worksheets(b).Move before:=Worksheets(a)
End If
Next b
Next a
Application.ScreenUpdating = True
End Sub
VBA code for that is as follows:
Sub sortSheet()
Dim sheetcount, a, b As Integer
Application.ScreenUpdating = False
sheetcount = Worksheets.Count
If sheetcount = 1 Then Exit Sub
For a = 1 To sheetcount - 1
For b = a + 1 To sheetcount
If Worksheets(b).Name < Worksheets(a).Name Then
Worksheets(b).Move before:=Worksheets(a)
End If
Next b
Next a
Application.ScreenUpdating = True
End Sub
No comments:
Post a Comment