Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort the sheets 1

Status
Not open for further replies.

nfpk

Programmer
Joined
Aug 15, 2002
Messages
74
Location
SE
Hello!
Is it possible to sort the sheets in a workbook in alfabethical order? Is there a command for this?

nfpk
 
One way - Code from Dave McRitchie/Bill Manville:-

Sub SortALLSheets()
'modification of coded example by Bill Manville
Dim iSheet As Integer, iBefore As Integer
For iSheet = 1 To ActiveWorkbook.Sheets.Count
Sheets(iSheet).Visible = True
For iBefore = 1 To iSheet - 1
If UCase(Sheets(iBefore).Name) > UCase(Sheets(iSheet).Name) Then
ActiveWorkbook.Sheets(iSheet).Move Before:=ActiveWorkbook.Sheets(iBefore)
Exit For
End If
Next iBefore
Next iSheet
End Sub '-- SortALLSheets()

Regards
Ken..............
 
Thanks a lot, it works perfect!!!
 
My pleasure - Glad it helped.

Regards
Ken.........
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top