+ Reply to Thread
Results 1 to 3 of 3

trying to develop a spreadsheet that has an embedded keyword filter at top of page...

Hybrid View

  1. #1
    Registered User
    Join Date
    05-18-2012
    Location
    dc
    MS-Off Ver
    Excel 2007
    Posts
    2

    trying to develop a spreadsheet that has an embedded keyword filter at top of page...

    so a user can easy get to records in the file without using the excel filter function....making it super easy for anyone to use.

    can anyone help?


    Tony

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: trying to develop a spreadsheet that has an embedded keyword filter at top of page...

    Tony,

    Welcome to the forum!

    Attached is an example workbook based on the criteria you described.
    In cell B1 is a drop-down list of the column headers so you can choose which column you're filtering by.
    In cell B2 you can type in what you want to filter for.

    Changing either of those cells will trigger the worksheet_change event:
    Private Sub Worksheet_Change(ByVal Target As Range)
        
        Dim rngCol As Range
        Dim rngKey As Range
        Dim lCalc As Long
        Dim rngFilter As Range
        Dim LastRow As Long
        
        Set rngCol = Me.Range("B1")
        Set rngKey = Me.Range("B2")
        
        If Target.Address = rngCol.Address _
        Or Target.Address = rngKey.Address Then
            
            Me.AutoFilterMode = False
            If Len(rngCol.Value) = 0 Or Len(rngKey.Value) = 0 Then Exit Sub
            
            With Application
                lCalc = .Calculation
                .Calculation = xlCalculationManual
                .EnableEvents = False
                .ScreenUpdating = False
            End With
            On Error GoTo CleanExit
            
            LastRow = Me.Cells.Find("*", Me.Range("A1"), , , , xlPrevious).Row
            Set rngFilter = Me.Range("A4:E4").Find(rngCol.Value, , , xlWhole)
            Set rngFilter = Range(rngFilter, Me.Cells(LastRow, rngFilter.Column))
            rngFilter.AutoFilter 1, rngKey.Text
            
    CleanExit:
            With Application
                .Calculation = lCalc
                .EnableEvents = True
                .ScreenUpdating = True
            End With
        End If
        
    End Sub


    Is something like that what you're looking for?
    Attached Files Attached Files
    Last edited by tigeravatar; 05-18-2012 at 03:12 PM. Reason: Had to reupload attachment
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    05-18-2012
    Location
    dc
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: trying to develop a spreadsheet that has an embedded keyword filter at top of page...

    yeah thats even more than I need...only need the function on B2 to scan two columns and filter on the text inputed.

    thanks so much...

    Tony

+ 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