I have a nifty TOC that I am pretty happy with, but I would like for the sheet list to populate without the TOC sheet in it. I would also like to apply this same idea to alphabetizing the tab order, to not include the TOC in the alphabetization of the sheet tabs. Here are the codes that I have thus far -
Create Directory List
Sub ListSheets()
Dim ws As Worksheet
Dim x As Integer
x = 1
Sheets("DIRECTORY").Range("A:A").Clear
For Each ws In Worksheets
Sheets("DIRECTORY").Cells(x, 1).Select
ActiveSheet.Hyperlinks.Add _
Anchor:=Selection, Address:="", SubAddress:= _
ws.Name & "!A1", TextToDisplay:=ws.Name
x = x + 1
Next ws
End Sub
Alphabetize the tabs -
Option Explicit
Sub SortWorksheets()
Dim N As Integer
Dim M As Integer
Dim FirstWSToSort As Integer
Dim LastWSToSort As Integer
Dim SortDescending As Boolean
SortDescending = False
If ActiveWindow.SelectedSheets.Count = 1 Then
'Change the 1 to the worksheet you want sorted first
FirstWSToSort = 1
LastWSToSort = Worksheets.Count
Else
With ActiveWindow.SelectedSheets
For N = 2 To .Count
If .Item(N - 1).Index <> .Item(N).Index - 1 Then
MsgBox "You cannot sort non-adjacent sheets"
Exit Sub
End If
Next N
FirstWSToSort = .Item(1).Index
LastWSToSort = .Item(.Count).Index
End With
End If
For M = FirstWSToSort To LastWSToSort
For N = M To LastWSToSort
If SortDescending = True Then
If UCase(Worksheets(N).Name) > UCase(Worksheets(M).Name) Then
Worksheets(N).Move Before:=Worksheets(M)
End If
Else
If UCase(Worksheets(N).Name) < UCase(Worksheets(M).Name) Then
Worksheets(N).Move Before:=Worksheets(M)
End If
End If
Next N
Next M
End Sub
Bookmarks