Results 1 to 2 of 2

Thread: Sort table by color
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular Dr. Demento's Avatar
    Join Date
    Nov 2010
    Location
    Skipping stones off Charon's Ferry
    Posts
    534
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Sort table by color

    At one point, I had this working, but with all my futzing, I've jacked it up. Can anyone point out why nothing gets sorted?? The colors are the standard yellow, light green, and light blue from the default color palette. I'm at a complete loss; I tried using both .ListColumns and .HeaderRowRange - no errors but no sorting happens either.

    Thanks y'all.

    Code:
    Sub demo_filter_byColor()
      filter_byColor ActiveSheet.ListObjects(1), Array(1, 1, 1), Array(1703935, 15773696, 5296274)
    End Sub
    
    
    
    Sub filter_byColor(lbt As ListObject, _
                       rraCol As Variant, _
                       rraColor As Variant)
    '                  rraFontFill As Variant
    Const proc_name$ = "filter_byColor"
    Dim i As Long, _
        lColor As Long
    '  If Not ((UBound(rraCol) - LBound(rraCol)) = (UBound(rraFontFill) - LBound(rraFontFill)) And _
    '          (UBound(rraCol) - LBound(rraCol)) = (UBound(rraColor) - LBound(rraColor))) Then _
    '    Exit Sub
      
      Application.ScreenUpdating = False
      For i = LBound(rraCol) To UBound(rraCol)
        With lbt.Sort
          .SortFields.Clear
        
    '        Select Case rraFontFill(i)
    '          Case "Fill"
          .SortFields.Add(lbt.HeaderRowRange(rraCol(i)), xlSortOnCellColor, _
                          xlAscending, , xlSortNormal).SortOnValue.color = rraColor(1)
              
    '          Case "Font"
          .SortFields.Add(lbt.ListColumns(rraCol(i)).DataBodyRange, xlSortOnFontColor, _
                               xlAscending, , xlSortNormal).SortOnValue.color = rraColor(i)  'Range(rraCol(i))
            
    '        End Select
            
          .Header = xlYes
          .MatchCase = False
          .Orientation = xlTopToBottom
          .SortMethod = xlPinYin
          .Apply
          
        End With 'lbt.Sort
        
      Next i
      
      Application.ScreenUpdating = True
    End Sub

  2. #2
    Board Regular Dr. Demento's Avatar
    Join Date
    Nov 2010
    Location
    Skipping stones off Charon's Ferry
    Posts
    534
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Sort table by color

    Thoughts anyone?
    Last edited by Dr. Demento; May 16th, 2019 at 10:36 PM.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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