Consulting

Results 1 to 2 of 2

Thread: sort worksheets by tabcolor

  1. #1
    VBAX Regular
    Joined
    Jan 2007
    Posts
    28
    Location

    sort worksheets by tabcolor

    I have a workbook withabout 100 sheets for which I would like to sort by tab color if possible. There are 5 colors I use to differentiate them.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Public Sub Test()
    Dim i As Long

    With ActiveWorkbook

    For i = 1 To .Worksheets.Count - 1

    If .Worksheets(i).Tab.ColorIndex > .Worksheets(i + 1).Tab.ColorIndex Then

    .Worksheets(i + 1).Move before:=.Worksheets(i)
    i = 0
    End If
    Next i
    End With

    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •