Thursday, September 10, 2015

Sort Worksheets

Order tabs

Worksheets can be dragged and dropped into any order required. They can be set up in numeric or alpha order, but doing it by hand is a bother.

Chip Pearson has written some macros that will do the job for you:
  • Sorting Worksheets In Alphabetical Order
  • Sorting In Custom Order
  • Grouping Sheets By Color

Here's the code to sort by tab color:

Sub GroupSheetsByColor()
Dim Ndx As Long
Dim Ndx2 As Long
For Ndx = 1 To Worksheets.Count - 1
For Ndx2 = Ndx To Worksheets.Count
If Worksheets(Ndx2).Tab.ColorIndex = _
Worksheets(Ndx).Tab.ColorIndex Then
Worksheets(Ndx2).Move after:=Worksheets(Ndx)
End If
Next Ndx2
Next Ndx
End Sub

Sorting Worksheets In A Workbook

(The colorindex variable chooses one of the 56 colors in Excel's basic palette.
Here are all the colors and numbers as compiled by F. David McRitchie:
Excel Colors )

See all Topics

No comments: