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
'變數設定
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
留言
張貼留言