I have written a code with a for loop that filters certain data for a particular date. It runs perfectly for the first loop, however, in the second loop, it doesnt filter and instead hides all the data. Can somebody please explain to me why this is happening.

For a = 5 To b

Sheets("lists").Select
e = Cells(a, 44)
Cells(a, 44).Select

k = Sheets("lists").Range("AW3") + 5


If e > d Then
Range("AR5").Select

ElseIf e < d Or e = d Then
Sheets("sample data").Select
ActiveSheet.Range("$B$6:$T$500").AutoFilter Field:=1
ActiveSheet.Range("$B$6:$T$500").AutoFilter Field:=1, Criteria1:="=" & e
Range("I6").Select

This is the section of the code that is not working correctly. 'e' & 'd' are dates.