ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sorting sheets (https://www.excelbanter.com/excel-programming/278583-sorting-sheets.html)

emilija

Sorting sheets
 
I have a book with a lot of sheets ( more then 200) , is it possible to
sort sheets in alphabetical order,
Thanks in advance



Tom Ogilvy

Sorting sheets
 
Chip Pearson has documented some code to do this:

http://www.cpearson.com/excel/sortws.htm

--
Regards,
Tom Ogilvy

"emilija" wrote in message
...
I have a book with a lot of sheets ( more then 200) , is it possible to
sort sheets in alphabetical order,
Thanks in advance





losmac

Sorting sheets
 
'sort all sheets in workbook
'on first letter of sheet name

Sub SortSheets()
Dim shCount, i, j As Long

shCount = Worksheets.Count

For i = 1 To shCount
For j = i + 1 To shCount
If Asc(Left(Worksheets(j).Name, 1)) < _
Asc(Left(Worksheets(i).Name, 1)) Then
Worksheets(j).Move Befo=Worksheets(i)
End If
Next j
Next i

End Sub

I hope, it is helpful.

--
Sorry for my language, I'm still learning
losmac

Użytkownik "emilija" napisał w wiadomości
...
I have a book with a lot of sheets ( more then 200) , is it possible to
sort sheets in alphabetical order,
Thanks in advance






All times are GMT +1. The time now is 10:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com