Hi there
Below is the macro recorded as an example of the task, which is to first sort column by color and then filter column by color.
I want to keep elements about what sheet I am on, which table etc, but how could I change the specific range [(Range("t_coupon[[#All],[1/2]]")] and [Field:=32] in this example and make the code "global" for each column I manually select each time??
Thank you in advance Experts!!!!
Below is the macro recorded as an example of the task, which is to first sort column by color and then filter column by color.
I want to keep elements about what sheet I am on, which table etc, but how could I change the specific range [(Range("t_coupon[[#All],[1/2]]")] and [Field:=32] in this example and make the code "global" for each column I manually select each time??
Thank you in advance Experts!!!!
VBA Code:
Sub m_sort_n_filter_by_color()
'
' m_sort_n_filter_by_color Macro
'
'
ActiveWorkbook.Worksheets("Coupon").ListObjects("t_coupon").Sort.SortFields. _
Clear
ActiveWorkbook.Worksheets("Coupon").ListObjects("t_coupon").Sort.SortFields.Add _
(Range("t_coupon[[#All],[1/2]]"), xlSortOnCellColor, xlAscending, , _
xlSortNormal).SortOnValue.Color = RGB(255, 192, 0)
With ActiveWorkbook.Worksheets("Coupon").ListObjects("t_coupon").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveSheet.ListObjects("t_coupon").Range.AutoFilter Field:=32, Criteria1:= _
RGB(255, 192, 0), Operator:=xlFilterCellColor
End Sub