Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 08-04-2009
Member
 
Join Date: Jan 2009
Posts: 110
How can I use a variable in an autofilter in VBA

Hi friends,

Can any one help me out,I want to use a variable where it is going to be used for autofilter.


ActiveSheet.Range("$A$1:$S$277").AutoFilter Field:=1,
Criteria1:=">=StartDate", Operator:=xlAnd, Criteria2:="<=EndDate"


Where StartDate and EndDate would be assigned date values to filter between
those dates. I am using variable name instead of the value of the variable.

Variables are dim as variants.
Reply With Quote
  #2  
Old 08-04-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: How can I use a variable in an autofilter in VBA

Sure i will help you out with this issue try to use the following code hope it would work for you.

Criteria1:=">=" & StartDate
Reply With Quote
  #3  
Old 08-04-2009
Member
 
Join Date: Jan 2009
Posts: 110
Re: How can I use a variable in an autofilter in VBA

I try to follow the codes but it's not working for me and for more information i am using Excel 2002.
Reply With Quote
  #4  
Old 08-04-2009
Member
 
Join Date: May 2008
Posts: 2,008
Re: How can I use a variable in an autofilter in VBA

I was also facing similar kind of issue i try to use the following code and it worked for me.

Range("A1: D200").AutoFilter 2, ">=02/01/2001", xlAnd, "<=02/01/2001"
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How can I use a variable in an autofilter in VBA"
Thread Thread Starter Forum Replies Last Post
how to enable Autofilter and Sorting in Protected Excel Sheet ChittiBabu Windows Software 2 04-01-2012 08:38 PM
Excel autofilter stops filtering roumieh2000 Windows Software 3 15-10-2009 03:31 PM
Runtime Error 91 : Object Variable or with block variable not set Ryan21 Software Development 2 28-08-2009 07:51 PM
Microsoft Excel autofilter has stopped working McGrawh Windows Software 4 07-05-2009 02:31 PM
What is Global Variable static? Declaring static variable instead of Global variable Reckon Software Development 3 25-04-2009 11:34 AM


All times are GMT +5.5. The time now is 03:52 PM.