Sort Worksheet Tabs By Color @Exceltrainingvideos
Sort Worksheet Tabs By Color  @Exceltrainingvideos
Uploaded June 2020 | Updated November 2026, 2 days ago
How to sort worksheet tabs by color automatically using VBA.
Here's the complete VBA code:
Sub SortWorksheetTabsBycolor()

Dim CurrentSheetIndex As Long
Dim PreviousSheetIndex As Long

Application.ScreenUpdating = False

For CurrentSheetIndex = 1 To Sheets.Count

For PreviousSheetIndex = 1 To Sheets.Count - 1

If Sheets(PreviousSheetIndex).Tab.ColorIndex = Sheets(CurrentSheetIndex).Tab.ColorIndex Then
Sheets(PreviousSheetIndex).Move before:=Sheets(CurrentSheetIndex)
End If

Next PreviousSheetIndex
Next CurrentSheetIndex

Application.ScreenUpdating = True

End Sub

References:
(1) Color codes: dmcritchie.mvps.org/excel/colors.htm
(2) Refer to Sheets by Index Number: docs.microsoft.com/en-us/office/vba/excel/concepts/workbooks-and-worksheets/refer-to-sheets-by-index-number#:~:text=An%20index%20number%20is%20a,(1).Activate%20End%20Sub
(3)Worksheet.Move method (Excel):
docs.microsoft.com/en-us/office/vba/api/excel.worksheet.move

Details also available at exceltrainingvideos.com/sort-worksheet-tabs-by-color
Sort Worksheet Tabs By ColorGenerate Random Strings in Excel with VBADisplay Data in Listbox based on Combo Box SelectionCreate Floating ButtonForward Message via whatsapp DesktopSpeed Up MacrosPrevent Users From Pasting Data into Text Boxes on UserFormUsing Excel VBA to Create Reciprocal FormulasAnalyze Large Amounts of Data in ExcelCombine Worksheets Data Using Power QueryCreate Report from Duplicate Data in WorksheetConvert Each Worksheet in Workbook to Text File
Dinesh Kumar Takyar |

Sort Worksheet Tabs By Color

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER