I am trying to make my autofilter range based on the value of variables, but it isn't working. Does anyone have any suggestions?
Dim y, z As Integer
y = 5
z = 3
rows(z).Select
Selection.AutoFilter
ActiveWorkbook.Worksheets("Active Worksheet").AutoFilter.Sort.SortFields.Clear
**ActiveWorkbook.Worksheets("Active Worksheet").AutoFilter.Sort.SortFields.Add _
Key:=Range(Cells(z, y)), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal**
With ActiveWorkbook.Worksheets("Active Worksheet").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With