ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sorting the sheets in a workbook ? (https://www.excelbanter.com/excel-programming/435560-sorting-sheets-workbook.html)

Eric_in_EVV[_2_]

Sorting the sheets in a workbook ?
 
Is there a way to sort the sheets in a workbook to have them in alphabetical
order....other than manually moving them ?

Hoping for a "yes" answer.....and thanks !

Tom Hutchins

Sorting the sheets in a workbook ?
 
David McRitchie's site has this macro to sort the sheets in a workbook:

Sub SortALLSheets()
'sort sheets within a workbook in Excel 7 -- Bill Manville
'modified to sort all sheets instead of just worksheets
Dim iSheet As Long, iBefore As Long
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
Befo=ActiveWorkbook.Sheets(iBefore)
Exit For
End If
Next iBefore
Next iSheet
End Sub

His site is located at:
http://www.mvps.org/dmcritchie/excel...#sortallsheets

Hope this helps,

Hutch

"Eric_in_EVV" wrote:

Is there a way to sort the sheets in a workbook to have them in alphabetical
order....other than manually moving them ?

Hoping for a "yes" answer.....and thanks !


Eric_in_EVV[_2_]

Sorting the sheets in a workbook ?
 
I really was expecting the answer to be "no way can that be done"....so I'm
thrilled to see yuor reply. I'm going to copy the code below and check it
out...will also visit David McRitchie's site !

How Sweet it is !!

Thanks !!

"Tom Hutchins" wrote:

David McRitchie's site has this macro to sort the sheets in a workbook:

Sub SortALLSheets()
'sort sheets within a workbook in Excel 7 -- Bill Manville
'modified to sort all sheets instead of just worksheets
Dim iSheet As Long, iBefore As Long
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
Befo=ActiveWorkbook.Sheets(iBefore)
Exit For
End If
Next iBefore
Next iSheet
End Sub

His site is located at:
http://www.mvps.org/dmcritchie/excel...#sortallsheets

Hope this helps,

Hutch

"Eric_in_EVV" wrote:

Is there a way to sort the sheets in a workbook to have them in alphabetical
order....other than manually moving them ?

Hoping for a "yes" answer.....and thanks !



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

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