ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Is it possible to sort Excel sheet tabs; i.e. alphabetically? (https://www.excelbanter.com/excel-worksheet-functions/215210-possible-sort-excel-sheet-tabs%3B-i-e-alphabetically.html)

Darlene

Is it possible to sort Excel sheet tabs; i.e. alphabetically?
 

--
Darlene

excel-ant

Is it possible to sort Excel sheet tabs; i.e. alphabetically?
 
On 2 Jan, 20:49, Darlene wrote:
--
Darlene


Yes,

I found the following code----

Sub SortSheets()

Dim lCount As Long, lCounted As Long

Dim lShtLast As Long

Dim lReply As Long

lReply = MsgBox("To sort Worksheets ascending, select 'Yes'. " _

& "To sort Worksheets descending select 'No'", vbYesNoCancel, "Ozgrid
Sheet Sort")

If lReply = vbCancel Then Exit Sub

lShtLast = Sheets.Count

If lReply = vbYes Then 'Sort ascending

For lCount = 1 To lShtLast

For lCount2 = lCount To lShtLast

If UCase(Sheets(lCount2).Name) < UCase(Sheets
(lCount).Name) Then

Sheets(lCount2).Move Befo=Sheets(lCount)

End If

Next lCount2

Next lCount

Else 'Sort descending

For lCount = 1 To lShtLast

For lCount2 = lCount To lShtLast

If UCase(Sheets(lCount2).Name) UCase(Sheets
(lCount).Name) Then

Sheets(lCount2).Move Befo=Sheets(lCount)

End If

Next lCount2

Next lCount

End If

------------------------------------------------------

Anthony
http://www.excel-ant.co.uk

Mike H

Is it possible to sort Excel sheet tabs; i.e. alphabetically?
 
Hi,

Right click any sheet tab, view code and paste this in and run it

Sub Sortem()
LastSheet = Sheets.Count
For ws = 1 To LastSheet
For ws2 = ws To LastSheet
If UCase(Sheets(ws2).Name) < UCase(Sheets(ws).Name) Then
Sheets(ws2).Move Befo=Sheets(ws)
End If
Next ws2
Next ws
End Sub

Mike

"Darlene" wrote:


--
Darlene


Shane Devenshire[_2_]

Is it possible to sort Excel sheet tabs; i.e. alphabetically?
 
Hi,

1. There is no command built into Excel to do this.
2. You need to use VBA code to do it and here is a site with just that:
http://www.cpearson.com/excel/sortws.aspx

--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"Darlene" wrote:


--
Darlene


LinLin

Is it possible to sort Excel sheet tabs; i.e. alphabetically?
 
Hi Darlene

There is an excellent solution he

http://www.contextures.com/xlToolbar01.html

It allows you to sort the tabs AND also naviagte them easily.
Very easy to set up - just follow the instructions.

"Darlene" wrote:


--
Darlene



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

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