Results 1 to 4 of 4

Thread: How can I use a variable in an autofilter in VBA

  1. #1
    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.

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    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

  3. #3
    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.

  4. #4
    Join Date
    May 2008
    Posts
    2,012

    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"

Similar Threads

  1. how to enable Autofilter and Sorting in Protected Excel Sheet
    By ChittiBabu in forum Windows Software
    Replies: 2
    Last Post: 04-01-2012, 08:38 PM
  2. Excel autofilter stops filtering
    By roumieh2000 in forum Windows Software
    Replies: 3
    Last Post: 15-10-2009, 03:31 PM
  3. Replies: 2
    Last Post: 28-08-2009, 07:51 PM
  4. Microsoft Excel autofilter has stopped working
    By McGrawh in forum Windows Software
    Replies: 4
    Last Post: 07-05-2009, 02:31 PM
  5. Replies: 3
    Last Post: 25-04-2009, 11:34 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,103,614.82348 seconds with 16 queries