ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   sort tabs in a workbook other than one at a time with move or cop. (https://www.excelbanter.com/excel-worksheet-functions/10273-sort-tabs-workbook-other-than-one-time-move-cop.html)

Hoflinger

sort tabs in a workbook other than one at a time with move or cop.
 
is there any way to sort worksheets other than using the move or copy option?
How to alphabetize multiple sheets at one time.

Bony Pony

Try this:


Sub Sort_Active_Book()
Dim i As Integer
Dim j As Integer
Dim iAnswer As VbMsgBoxResult
' Prompt the User as to which direction they want to sort
the worksheets.
iAnswer = MsgBox("Sort sheets in Ascending Order?" & Chr
(10) & "Clicking NO will sort in DESCENDING order",
vbYesNoCancel + vbQuestion + vbDefaultButton1, "Sort
Worksheets")
For i = 1 To Sheets.Count
For j = 1 To Sheets.Count - 1
' If answer is YES, sort ASCENDING
If iAnswer = vbYes Then
If UCase$(Sheets(j).Name) UCase$(Sheets(j + 1).Name)
Then Sheets(j).Move After:=Sheets(j + 1)
End If


' If Answer is NO, sort DESCENDING

If iAnswer = vbNo Then
If UCase$(Sheets(j).Name) < UCase$(Sheets(j + 1).Name)
Then Sheets(j).Move After:=Sheets(j + 1)
End If


Next j
Next i


End Sub


It's not mine but it works

Good luck!
-----Original Message-----
is there any way to sort worksheets other than using the

move or copy option?
How to alphabetize multiple sheets at one time.
.



All times are GMT +1. The time now is 07:01 PM.

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