Dr. Demento
Well-known Member
- Joined
- Nov 2, 2010
- Messages
- 618
- Office Version
- 2019
- 2016
- Platform
- Windows
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.
Thanks y'all.
Code:
[/FONT][/COLOR][/LEFT]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