Viktor
09-24-2014, 07:51 AM
Hi everyone,
I could use some help with a macro which filters a column of dates based on two dates that the user enters OR if the cell is empty.
This is what I have so far:
Sub CPT_Macro()
Dim lngStart As Long, lngEnd As Long
lngStart = InputBox("Enter stard date of interest")
lngEnd = InputBox("Enter end date of interest")
Range("AH7:AH8000").AutoFilter field:=1, _
Criteria1:=">=" & lngStart, _
Operator:=xlAnd, _
Criteria2:="<=" & lngEnd
Operator:=xlOr, _
Criteria3:=""
End Sub
There seem to be two problems:
1. I get a Type mismatch error as soon as I enter the start date (using dd.mm.yyyy, if that matters)
2. The two lines starting with "Operator:=xlOr, _" are red (maybe I cant autofilter with xlOr?)
I hope someone smarter can figure this out - thanks a lot!
Viktor
I could use some help with a macro which filters a column of dates based on two dates that the user enters OR if the cell is empty.
This is what I have so far:
Sub CPT_Macro()
Dim lngStart As Long, lngEnd As Long
lngStart = InputBox("Enter stard date of interest")
lngEnd = InputBox("Enter end date of interest")
Range("AH7:AH8000").AutoFilter field:=1, _
Criteria1:=">=" & lngStart, _
Operator:=xlAnd, _
Criteria2:="<=" & lngEnd
Operator:=xlOr, _
Criteria3:=""
End Sub
There seem to be two problems:
1. I get a Type mismatch error as soon as I enter the start date (using dd.mm.yyyy, if that matters)
2. The two lines starting with "Operator:=xlOr, _" are red (maybe I cant autofilter with xlOr?)
I hope someone smarter can figure this out - thanks a lot!
Viktor