+ Reply to Thread
Results 1 to 4 of 4

How do you input user defined variables into an AutoFilter statement?

  1. #1
    Registered User
    Join Date
    07-03-2010
    Location
    San Antonio Texas
    MS-Off Ver
    Excel 2007
    Posts
    3

    How do you input user defined variables into an AutoFilter statement?

    I am trying to create a macro which allows a user to input a begining date and ending date which in then input into the macro to select rows for coping and pasting to a new sheet.

    I think I'm close with the following code. The problem is I do not know how to call the Variables into the Criteria for the AutoFilter.
    Please Login or Register  to view this content.



    Any help would be much appreciated.

    Tony
    Last edited by trhoades; 07-14-2010 at 11:11 PM. Reason: Added Code Tags

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Need help inputting user defined variables into an AutoFilter statement

    Hello Tony,

    I made the changes in bold.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    07-03-2010
    Location
    San Antonio Texas
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: How do you input user defined variables into an AutoFilter statement?

    Leith thank you for your suggestion but I must be doing something wrong. When I make the changes suggested I get the following error:

    ActiveSheet.Range("$A$1:$F$45").AutoFilter Field:=1, Criteria1:= _
    ">=" & MyInput1", Operator:=xlAnd, Criteria2:="<=" & MyInput2"

    I receive a compile error?

    Any suggestions as to what I may be doing wrong?

  4. #4
    Registered User
    Join Date
    07-03-2010
    Location
    San Antonio Texas
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: How do you input user defined variables into an AutoFilter statement?

    Leith I found it. I see know that I included unnecessary " marks.

    Thank you very much for you assistance.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1