I think you're still getting confused about what VBA is doing and what Excel is 
doing.
(which are actually two different things)
VBA is a programming language.
Visual Basic for Applications.
 
It can be USED for Excel, Word, Access, Powerpoint.
 
There are variations in VBA for each application.
Word doesn't have a Range object, so any VBA statement involving Ranges and 
cells is specific to the Excel application.
 
So, VBA can be used to affect Excel.
 
But Excel isn't used to affect VBA.
 
In your case, the Filter is part of Excel.
 
We can use VBA to affect the Excel filter.
 
But the filter itself isn't part of VBA, it's part of Excel.
So your statement:
"confused here about the date filters in VBA specifically about their 
declaration"
is not accurate (well, I suppose the "confused" part is :)
because the date filter isn't IN VBA, nor are the filters being declared.
VBA is passing the filter requirements to Excel.
 
 
Now, in my code snippet, I declared a variable: Yesterday.
But I didn't declare a data type.
 
VBA makes the default data type "Variant".
curiously I've encountered cases where the first time a Variant data type is 
used, it is "recast" as a different type.
For instance, if I were to use:
Yesterday = 1
it might be recast as an integer 
yet, when I used:
Yesterday = Format(Now() - 1, "m/d/yyyy")
it was "recast" as a string.
 
the function:
ActiveSheet.Range("$A$1:$A$65000").AutoFilter _
    Field:=1, _
    Operator:=xlFilterValues, _
    Criteria2:=Array(2, Yesterday)
 
actually manages to (I think) cast the Array() as a Variant data type.
 
So.. 
in THIS case, it didn't really matter what data type I used.
 
If I used:
 
Dim Yesterday as Date
 
it works just as well.
 

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 12:35 PM
>Subject: RE: $$Excel-Macros$$ Applying Date Filters using VBA
>  
>
>
>Hi Ashish,
>
>
>Its working for Dates <9/25/2014 but not for =9/25/2014. Paul's code extract 
>worked. But I guess I am confused here about the date filters in VBA 
>specifically about their declaration, do I really need to declare datatype, or 
>it will automatically get changed to the application specific if we do not 
>declare its datatype.
>
>
>I had done this thing (date filters) in three different macros and used three 
>different methods.
>
>
>Thanks all for your efforts. I really need to work hard on this.
>
>
>Regards.
>
>
>Yours Sincerely,
>Nitin Balodi
>
>
>Date: Fri, 26 Sep 2014 20:57:18 +0530
>Subject: Re: $$Excel-Macros$$ Applying Date Filters using VBA
>From: kumar.ashish...@gmail.com
>To: excel-macros@googlegroups.com
>
>
>Hi Nitin,
>
>
>PFA.....!
>
>
>
>
>Regards
>Ashish 
>-- 
>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.

Reply via email to