I need a macro to sort several tabs by cell color, putting the colored cells on the top. When I use the macro recorder it records this:


 Range("A1:J1000").Select
    ActiveWorkbook.Worksheets("COOP QA1").sort.SortFields.Clear
    ActiveWorkbook.Worksheets("COOP QA1").sort.SortFields.Add(Range("A2:A50"), _
        xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = RGB(124, 21 _
        , 0)
    With ActiveWorkbook.Worksheets("COOP QA1").sort
        .SetRange Range("A1:J50")
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
I need it to not include the worksheet name so that it will work on multiple tabs, but when I take the worksheet name out it doesn't work. Any ideas why this code doesn't run?

 Range("A1:J1000").Select
    ActiveWorksheet.sort.SortFields.Clear
    Activeworksheet.sort.SortFields.Add(Range("A2:A50"), _
        xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = RGB(124, 21 _
        , 0)
    With Activeworksheet.sort
        .SetRange Range("A1:J50")
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With