Sort tabs by color and sort color groups alphabetically

  • I've located the following color sort VBA that sorts worksheets by color and it is working well.
    I'm trying to modify the code to sort each of the "color grouped" sheets alphabetically. That is, sort by color and then each color group sorted alphabetically.
    I'm really stumped and appreciate any help / guidance.

  • Re: Sort tabs by color and sort color groups alphabetically


    Thanks for your quick response.
    I pasted your VBA code in and I'm getting error message:
    Runtime error '13':
    Type mismatch
    in:
    Private Sub mySort(a, ref)
    Statement line:
    For i = LBound(a, 2) To UBound(a, 2) - 1


    Is there something I should be changing in the code?
    My worksheets (tabs) are empoyee names, no numeric values.
    Thanks for your help

  • Re: Sort tabs by color and sort color groups alphabetically


    Try change to

  • Re: Sort tabs by color and sort color groups alphabetically


    Thanks so much!
    The code works well!!
    Could you, please, briefly explain why the previous code you recommended did not work for my situation and what changes were required?
    Also, If I change the color values in statement:myColor = VBA.Array(65535, 12611584, 255, 49407, 5296274), will other code changes be required?
    Your help is greatly appreciated.

  • Re: Sort tabs by color and sort color groups alphabetically


    The code in the link was on the assumption that the color(s) specified are exist, so I didn't consider about the bug that you got.


    Here's the generalized code.
    If you specify the colors, it will sort in order of myColor first and sort within the respective color, otherwise it will sort by the color accroding to the order of appearance and sort within such color.

  • Do not reports posts to gain attention.


    Please start your own post. Posting in another member's Thread is known as hijacking and is not allowed here. By all means add a link to a Thread that may be related to your question.


    I suggest that you read the Forum Rules before continuing.

  • royUK

    Closed the thread.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!