OzGrid

Group Excel Worksheets/Sheets by Color

< Back to Search results

 Category: [Excel]  Demo Available 

Group Excel Worksheets/Sheets by Color

 

Group Excel Sheets/Worksheets by Color. Grouping Excel Worksheets by Color


In Excel 2000, Microsoft introduced the ability to color the Sheet name tabs. The Excel VBA macro code below can be used in any Excel Workbook that is at least Excel 2000, or higher. When run it will group all Sheets in the active Workbook by their tab color. To use the code, go to Tools>Macro>Visual Basic Editor (Alt+F11) and then to Insert>Module and paste in the code below.

Sub GroupSheetsByColor()

Dim lCount As Long, lCounted As Long

Dim lShtLast As Long



lShtLast = Sheets.Count



        For lCount = 1 To lShtLast

            For lCounted = lCount To lShtLast

                If Sheets(lCounted).Tab.ColorIndex = Sheets(lCount).Tab.ColorIndex Then

                    Sheets(lCounted).Move Before:=Sheets(lCount)

                End If

            Next lCounted

        Next lCount

   

End Sub

 

See also:

Convert Excel Formulas from Relative to Absolute
Custom Excel Formulas - User Defined Functions/Formulas
Parse/Extract File Name from Full File Name and Path
Excel: Get Maximum Number Between 2 Numbers

 

See also Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions.

 

Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.


Gallery



stars (0 Reviews)