WHAT have you tried? WHAT are you trying? I took your sample. Recorded a macro in which I turned on AutoFilter, and filtered to show yesterday's date. Then, I looked at the macro and created a variable to calculate "yesterday's" date and substituted this variable into the macro. THEN, I went ahead and added some tests so that if AutoFilter were already on, it wouldn't try to turn it on again (which actually would turn it OFF) Then, I also "undid" any existing filters by using .ShowAllData I ended up with this: Dim Yesterday Yesterday = Format(Now() - 1, "m/d/yyyy") If (Not ActiveSheet.AutoFilterMode) Then ActiveSheet.Columns("A:A").AutoFilter If (ActiveSheet.FilterMode) Then ActiveSheet.ShowAllData ActiveSheet.Range("$A$1:$A$65000").AutoFilter Field:=1, Operator:= _ xlFilterValues, Criteria2:=Array(2, Yesterday)
but, since I don't know what you're trying, I don't know if this is even CLOSE to being what you're looking for! Paul ----------------------------------------- “Do all the good you can, By all the means you can, In all the ways you can, In all the places you can, At all the times you can, To all the people you can, As long as ever you can.” - John Wesley ----------------------------------------- From: Nitin Balodi <nitinbal...@live.com> >To: "excel-macros@googlegroups.com" <excel-macros@googlegroups.com> >Sent: Friday, September 26, 2014 10:45 AM >Subject: RE: $$Excel-Macros$$ Applying Date Filters using VBA > > > >Hi Vaibhav, > > >I have tried again applying filters on the data but still not getting the >filtered result. I want to filter yesterday date basis on current date and the >date format will always be mm-dd-yyyy hh:mm. > > > > > >Regards. > > >Yours Sincerely, >Nitin Balodi > > >From: nitinbal...@live.com >To: excel-macros@googlegroups.com >Subject: RE: $$Excel-Macros$$ Applying Date Filters using VBA >Date: Fri, 26 Sep 2014 20:01:13 +0530 > > >Hi Vaibhav, > > >Thanks for the link. It certainly clear many concepts regarding date filters. > > >Regards. > > >Yours Sincerely, >Nitin Balodi > > >From: v...@vabs.in >Date: Fri, 26 Sep 2014 18:38:09 +0530 >Subject: Re: $$Excel-Macros$$ Applying Date Filters using VBA >To: excel-macros@googlegroups.com > > >Refer this: http://www.ozgrid.com/VBA/autofilter-vba-dates.htm > > >Cheers!! > > >+++++ >I did not do this for you. God is here working through me for you. > > >On Fri, Sep 26, 2014 at 5:41 PM, Nitin Balodi <nitinbal...@live.com> wrote: > >Hi experts, >> >> >>I want to apply date filter in the attached sheet for previous date using >>VBA. Could you please guide me how to apply date filters as I am struggling >>to apply these especially with their formats and declaration while writing >>code. >> >> >>I mean sometimes I have to declare them as Date datatype and sometimes as >>string and sometimes I have to Format them according to my requirement. Is >>there any generic datatype for date that works for any format. >> >> >> >> >>Regards. >> >> >>Yours Sincerely, >>Nitin Balodi >>-- >>Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s >>=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ >>https://www.facebook.com/discussexcel >> >>FORUM RULES >> >>1) Use concise, accurate thread titles. Poor thread titles, like Please Help, >>Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not >>get quick attention or may not be answered. >>2) Don't post a question in the thread of another member. >>3) Don't post questions regarding breaking or bypassing any security measure. >>4) Acknowledge the responses you receive, good or bad. >>5) Jobs posting is not allowed. >>6) Sharing copyrighted material and their links is not allowed. >> >>NOTE : Don't ever post confidential data in a workbook. Forum owners and >>members are not responsible for any loss. >>--- >>You received this message because you are subscribed to the Google Groups "MS >>EXCEL AND VBA MACROS" group. >>To unsubscribe from this group and stop receiving emails from it, send an >>email to excel-macros+unsubscr...@googlegroups.com. >>To post to this group, send email to excel-macros@googlegroups.com. >>Visit this group at http://groups.google.com/group/excel-macros. >>For more options, visit https://groups.google.com/d/optout. >> >> > > > >-- >Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s >=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ >https://www.facebook.com/discussexcel > >FORUM RULES > >1) Use concise, accurate thread titles. Poor thread titles, like Please Help, >Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get >quick attention or may not be answered. >2) Don't post a question in the thread of another member. >3) Don't post questions regarding breaking or bypassing any security measure. >4) Acknowledge the responses you receive, good or bad. >5) Jobs posting is not allowed. >6) Sharing copyrighted material and their links is not allowed. > >NOTE : Don't ever post confidential data in a workbook. Forum owners and >members are not responsible for any loss. >--- >You received this message because you are subscribed to the Google Groups "MS >EXCEL AND VBA MACROS" group. >To unsubscribe from this group and stop receiving emails from it, send an >email to excel-macros+unsubscr...@googlegroups.com. >To post to this group, send email to excel-macros@googlegroups.com. >Visit this group at http://groups.google.com/group/excel-macros. >For more options, visit https://groups.google.com/d/optout. > > >-- >Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s >=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ >https://www.facebook.com/discussexcel > >FORUM RULES > >1) Use concise, accurate thread titles. Poor thread titles, like Please Help, >Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get >quick attention or may not be answered. >2) Don't post a question in the thread of another member. >3) Don't post questions regarding breaking or bypassing any security measure. >4) Acknowledge the responses you receive, good or bad. >5) Jobs posting is not allowed. >6) Sharing copyrighted material and their links is not allowed. > >NOTE : Don't ever post confidential data in a workbook. Forum owners and >members are not responsible for any loss. >--- >You received this message because you are subscribed to the Google Groups "MS >EXCEL AND VBA MACROS" group. >To unsubscribe from this group and stop receiving emails from it, send an >email to excel-macros+unsubscr...@googlegroups.com. >To post to this group, send email to excel-macros@googlegroups.com. >Visit this group at http://groups.google.com/group/excel-macros. >For more options, visit https://groups.google.com/d/optout. > >-- >Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s >=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ >https://www.facebook.com/discussexcel > >FORUM RULES > >1) Use concise, accurate thread titles. Poor thread titles, like Please Help, >Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get >quick attention or may not be answered. >2) Don't post a question in the thread of another member. >3) Don't post questions regarding breaking or bypassing any security measure. >4) Acknowledge the responses you receive, good or bad. >5) Jobs posting is not allowed. >6) Sharing copyrighted material and their links is not allowed. > >NOTE : Don't ever post confidential data in a workbook. Forum owners and >members are not responsible for any loss. >--- >You received this message because you are subscribed to the Google Groups "MS >EXCEL AND VBA MACROS" group. >To unsubscribe from this group and stop receiving emails from it, send an >email to excel-macros+unsubscr...@googlegroups.com. >To post to this group, send email to excel-macros@googlegroups.com. >Visit this group at http://groups.google.com/group/excel-macros. >For more options, visit https://groups.google.com/d/optout. > > > -- Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Jobs posting is not allowed. 6) Sharing copyrighted material and their links is not allowed. NOTE : Don't ever post confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To unsubscribe from this group and stop receiving emails from it, send an email to excel-macros+unsubscr...@googlegroups.com. To post to this group, send email to excel-macros@googlegroups.com. Visit this group at http://groups.google.com/group/excel-macros. For more options, visit https://groups.google.com/d/optout.