Excel Sort.SortFields.add 依自訂顏色排序

Function Fn2_依顏色排序()

    '變數設定
        Set Sht348 = Sheets(LotoShowCon & "取位")
    '自定顏色排序
        With Sht348.Sort.SortFields
            .Clear
            .Add(Range("F20:F27"), _
                xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = #eeece1
            .Add(Range("F20:F27"), _
                xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = #4f81bd
            .Add(Range("F20:F27"), _
                xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = #c0504d
            .Add(Range("F20:F27"), _
                xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = #9bbb59
            .Add(Range("F20:F27"), _
                xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = #8064a2
            .Add(Range("F20:F27"), _
                xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = #4bacc6
            .Add(Range("F20:F27"), _
                xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = #f79646
        End With
    '執行排序動作
        With Sht348.Sort
            .SetRange Range("F20:F27")
            .Header = xlGuess
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
End Function

留言

這個網誌中的熱門文章

超任 三國志3代,登入武將金手指

歐姆龍 HEM-7600T 評價,購買心得分享(打臉文)

年青人眼鏡評價(負評),辛酸血淚史分享文