Greetings.
Im trying to autofilter a data range with the value of a specific cell as the criteria range, i.e filter a range based on the value of a cell. Here is my code, but it doest work.
Code
Sub Filter()
Dim k as integer
'k is value on cell B2 and the criteria range. The criteria range should be ">k"
k = Worksheets("Sheet1").Range("B2").Value
'Ive also tried Set k = Worksheets("Sheet1").Range("B2").Value but it also doesnt work
Columns("D:D").Select
Selection.AutoFilter
ActiveSheet.Range("D1:D500").AutoFilter Field:=1, Criteria1:=">k", Operator:=xlAnd
End sub
Display More
Please intervene.
Thanks