+ Reply to Thread
Results 1 to 3 of 3

Input box for filter

Hybrid View

  1. #1
    Registered User
    Join Date
    11-11-2011
    Location
    Essex
    MS-Off Ver
    Excel 2007
    Posts
    6

    Input box for filter

    Hello

    I have the following code

    Dim ws As Worksheet
        AutoFilterMode = False
        For Each ws In ActiveWorkbook.Worksheets
        ws.Activate
        Cells.Select
        Selection.AutoFilter
        ActiveSheet.Range("$A$1:$N$49").AutoFilter Field:=5, Criteria1:="<>"
        ActiveSheet.Range("$A$1:$N$49").AutoFilter Field:=2, Criteria1:="<>*480*", _
            Operator:=xlAnd
            
       Range("A2:A50").SpecialCells(xlCellTypeVisible).EntireRow.ClearContents
    Basically, I want an input box to input the text 480 or some other 3 digit number

    I can get the input box but I cannot make the filter to not contain the contents of the input box

    Any help would be appreciated

    cheers
    Last edited by pike; 11-11-2011 at 07:57 PM. Reason: add code tags for newbie

  2. #2
    Forum Contributor
    Join Date
    05-09-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    315

    Re: Input box for filter

    Make sure you enclose any code in code tags (# on the icon bar).

    Is this what you mean??

    Sub TEMP()
    
    Dim ws As Worksheet
    Dim varSearch As String
    
    varSearch = InputBox(Prompt:="Enter search string.", Title:="ENTER SEARCH STRING", Default:="")
    
    AutoFilterMode = False
    
    For Each ws In ActiveWorkbook.Worksheets
        ws.Activate
        Cells.Select
        Selection.AutoFilter
        ActiveSheet.Range("$A$1:$N$49").AutoFilter Field:=5, Criteria1:="<>"
        ActiveSheet.Range("$A$1:$N$49").AutoFilter Field:=2, Criteria1:="<>*" & varSearch & "*", Operator:=xlAnd
    Next ws
    
    End Sub

  3. #3
    Registered User
    Join Date
    11-11-2011
    Location
    Essex
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Input box for filter

    Fantastic, thank you very much for your help

+ 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