+ Reply to Thread
Results 1 to 3 of 3

Filter with input box

  1. #1
    Registered User
    Join Date
    09-25-2012
    Location
    Westlake, OH
    MS-Off Ver
    Excel 2010
    Posts
    3

    Filter with input box

    I'm new to the forum, and not very Excel savvy, so I apologize, I'm sure this question has been asked many times before, but, I can't find my answer. My need seems simple based on what I've been able to read here in the forums. I want to be able to filter a worksheet using two columns and want the user to input the filter criteria in an input box. Input 1= Filter Col A Input 2=Filter Col C. Essentially I can't rely on my users to use the drop down in auto filter mode so I need to give them an input box for the filter criteria. I hate to admit I also don't quite understand what renders the input box itself? Do I have to create the box or a button and associate with code? Thanks in advance for your patience and advice.

    L

  2. #2
    Registered User
    Join Date
    09-25-2012
    Location
    Westlake, OH
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Filter with input box

    Ok. I'm making a little progress on my own. I have adapted this code and it filters nicely for my first column of choice. Can I get a little help on how to achieve a second filter input box to achieve my two column filtering?

    "Sub FilterIt()
    Dim strCriteria As String
    Dim rFilterHeads As Range
    Dim wSheetStart As Worksheet



    Set wSheetStart = ActiveSheet
    Set rFilterHeads = Range("A1", Range("N1").End(xlToLeft))

    With wSheetStart
    .AutoFilterMode = False
    rFilterHeads.AutoFilter
    strCriteria = InputBox("Enter Territory Number")
    If strCriteria = vbNullString Then Exit Sub
    rFilterHeads.AutoFilter Field:=2, Criteria1:=strCriteria


    End With

    End Sub
    "

  3. #3
    Registered User
    Join Date
    09-25-2012
    Location
    Westlake, OH
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Filter with input box

    Ok still progressing , I'm able to filter two columns as I wanted to. Now I need the macro to run when the sheet is accessed so it automatically pops up.

    "Sub FilterIt()
    Dim strCriteria As String
    Dim rFilterHeads As Range
    Dim wSheetStart As Worksheet



    Set wSheetStart = ActiveSheet
    Set rFilterHeads = Range("A1", Range("N1").End(xlToLeft))

    With wSheetStart
    .AutoFilterMode = False
    rFilterHeads.AutoFilter
    strCriteria = InputBox("Enter Territory Number")
    If strCriteria = vbNullString Then Exit Sub
    rFilterHeads.AutoFilter Field:=2, Criteria1:=strCriteria
    strCriteria = InputBox("Enter Customer Number")
    If strCriteria = vbNullString Then Exit Sub
    rFilterHeads.AutoFilter Field:=5, Criteria1:=strCriteria


    End With

    End Sub"

+ 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