Hi All, I have some code that filters a range of data based on a unique number and the last 7 days. What I would like to do is be able to change the 7 days and put it as a variable so that it can be changed to whatever the user specifys. I am not sure on the syntax but basically i want the code to say filter based on todays date minus whatever is in cell "x"
This is my code, i have highlighted the required variable
.AutoFilterMode = False
.UsedRange.AutoFilter
.UsedRange.AutoFilter field:=1, Criteria1:="D5060"
.UsedRange.AutoFilter field:=2, Criteria1:="<=" & CLng(Date), Operator:=xlAnd, _
Criteria2:=">=" & CLng(Date - 7)
Thanks in advance
This is my code, i have highlighted the required variable
.AutoFilterMode = False
.UsedRange.AutoFilter
.UsedRange.AutoFilter field:=1, Criteria1:="D5060"
.UsedRange.AutoFilter field:=2, Criteria1:="<=" & CLng(Date), Operator:=xlAnd, _
Criteria2:=">=" & CLng(Date - 7)
Thanks in advance