Skip to content

Instantly share code, notes, and snippets.

@tanzilhuda
Created August 3, 2020 15:39
Show Gist options
  • Save tanzilhuda/c51e588f476965428d2ec9b3affa1c33 to your computer and use it in GitHub Desktop.
Save tanzilhuda/c51e588f476965428d2ec9b3affa1c33 to your computer and use it in GitHub Desktop.
==========================
--------Ascending---------
==========================
Sub SortSheets1()
Dim I As Integer
Dim J As Integer
For I = 1 To Sheets.Count - 1
For J = I + 1 To Sheets.Count
If UCase(Sheets(I).Name) > UCase(Sheets(J).Name) Then
Sheets(J).Move Before:=Sheets(I)
End If
Next J
Next I
End Sub
==========================
--------Descending---------
==========================
Sub SortSheets1()
Dim I As Integer
Dim J As Integer
For I = 1 To Sheets.Count - 1
For J = I + 1 To Sheets.Count
If UCase(Sheets(I).Name) < UCase(Sheets(J).Name) Then
Sheets(J).Move Before:=Sheets(I)
End If
Next J
Next I
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment