(Excel 2003, Windows XP Professional)
Hello,
I'm hoping someone can help me with the following problem............... I have written vba code in order to perform an autofilter between two dates, however my macro is not giving any results. If I step through the code, go into excel itself and open up the autofilter I can see that the correct criteria is present, and if i select 'OK' the desired results are given - however I cannot understand why using a macro means that this does not work. Could someone please point me in the right direction, a piece of the code is shown below
Dim dDate As Date
Dim strDate As String
Dim lDate As Long
dDate = DateSerial(YearBegin, MonthFrom, DayFrom)
lDate = dDate
eDate = DateSerial(YearEnd, MonthEnd, DayEnd)
mDate = eDate
If ActiveSheet.FilterMode Then ActiveSheet.ShowAllData
ActiveSheet.UsedRange.AutoFilter Field:=9, Criteria1:=">=" & lDate, Operator:=xlAnd _
, Criteria2:="<=" & mDate
Thanks in advance for any help you can provide
I have also posted this question in the following location, and have had some useful guidance but am still experiencing the same issues:
http://answers.yahoo.com/question/index?qid=20090803084728AAjDB7Z&r=w
Hello,
I'm hoping someone can help me with the following problem............... I have written vba code in order to perform an autofilter between two dates, however my macro is not giving any results. If I step through the code, go into excel itself and open up the autofilter I can see that the correct criteria is present, and if i select 'OK' the desired results are given - however I cannot understand why using a macro means that this does not work. Could someone please point me in the right direction, a piece of the code is shown below
Dim dDate As Date
Dim strDate As String
Dim lDate As Long
dDate = DateSerial(YearBegin, MonthFrom, DayFrom)
lDate = dDate
eDate = DateSerial(YearEnd, MonthEnd, DayEnd)
mDate = eDate
If ActiveSheet.FilterMode Then ActiveSheet.ShowAllData
ActiveSheet.UsedRange.AutoFilter Field:=9, Criteria1:=">=" & lDate, Operator:=xlAnd _
, Criteria2:="<=" & mDate
Thanks in advance for any help you can provide
I have also posted this question in the following location, and have had some useful guidance but am still experiencing the same issues:
http://answers.yahoo.com/question/index?qid=20090803084728AAjDB7Z&r=w