Consulting

Results 1 to 4 of 4

Thread: Auto filter criteria

  1. #1

    Auto filter criteria

    Hi all,
    Stuck with a problem, it may be simple but I'm just not getting it.
    Userform1 has a textbox in which I put a value, want the autofilter to filter between + or - 10 of that number
    I have tried textbox1.value & "<10" and a couple of different variations, syntax has me stuffed.

    Also textbox2.value to filter one column and textbox3.value to filter another and give me either results, I can get them to work individually however not together.
    Any help appreciated spent hours searching for the answer found heaps of solutions for filtering different values on one column,
    no xlOr for 2 columns.
    Cheers

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
        rng.AutoFilter Field:=1, _
                       Criteria1:=">=" & TextBox1.Value - 10, _
                       Operator:=xlAnd, _
                       Criteria2:="<=" & TextBox1.Value + 10
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    thanks xld works like a charm, I think i might have the xlOr bit.....

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    That would have to be two filters, xlOr refers to a filter being A or B, not column A Or column B.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •