+ Reply to Thread
Results 1 to 3 of 3

UserFrom filter between two values not working

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-12-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    163

    UserFrom filter between two values not working

    I have a user form that sorts a table in excel based off of 3 criterias. all criterias are entered in there own text box in a userform.
    the first one is the ID and the 2nd and 3rd criterias are a start number and end number. i want to filter the ID then get all of that ID thats contained between the two numbers. the problem is i dont know how to call upon the textbox and filter between the numbers. heres is the code i can filter the ID.

    Sub Macro3()
    ' Macro3 Macro
           ActiveSheet.ListObjects("Table_D04_Roadway_Inventory").Range.AutoFilter Field _
            :=3, Criteria1:=Me.TextBox1.Value, Operator:=xlAnd
            ActiveSheet.ListObjects("Table_D04_Roadway_Inventory").Range.AutoFilter Field _
            :=11, Criteria1:=">=Me.TextBox2.Value", Operator:=xlAnd, Criteria2:="<=Me.TextBox3.Value"
       End Sub
    this is the part im having trouble with below

     ActiveSheet.ListObjects("Table_D04_Roadway_Inventory").Range.AutoFilter Field _
            :=11, Criteria1:=">=Me.TextBox2.Value", Operator:=xlAnd, Criteria2:="<=Me.TextBox3.Value"

    thanks

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: UserFrom filter between two values not working

    you need to build the string
    ActiveSheet.ListObjects("Table_D04_Roadway_Inventory").Range.AutoFilter Field _
            :=11, Criteria1:=">=" & Me.TextBox2.Value, Operator:=xlAnd, Criteria2:="<=" & Me.TextBox3.Value
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Forum Contributor
    Join Date
    08-12-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    163

    Re: UserFrom filter between two values not working

    thank you
    it always makes sense after i see it.

+ 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