+ Reply to Thread
Results 1 to 3 of 3

Filter data by double clicking on any cell in range A3:A11 on any worksheet in workbook

Hybrid View

  1. #1
    Registered User
    Join Date
    05-09-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Filter data by double clicking on any cell in range A3:A11 on any worksheet in workbook

    In the attached the code works for the item number located in Cell A1 on worksheet "801" when double clicked

    I would like to filter the "Data" worksheet by double clicking on any item # in range "A3:A11" on any of the other worksheets "801,802,803". Original workbook that I will adapt code to has 45+ worksheets.
    Item #s are unique.

    Private Sub Workbook_sheetBeforeDoubleClick(ByVal sh As Object, ByVal Target As Range, Cancel As Boolean)
    If Intersect(Target, Range("A1")) Is Nothing Then
    Else
        Sheets("Data").Select
        Selection.AutoFilter Field:=4, Criteria1:=Worksheets("801").Range("A1").Value
    End If
    End Sub
    Thank you for your assistance
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Filter data by double clicking on any cell in range A3:A11 on any worksheet in workboo

    try
    Option Explicit
    
    Private Sub Workbook_sheetBeforeDoubleClick(ByVal sh As Object, ByVal Target As Range, Cancel As Boolean)
        If Not Intersect(Target, sh.Range("A3:A11")) Is Nothing And sh.Name <> "Data" Then
            With Worksheets("Data")
                If Not .AutoFilterMode Then .AutoFilter
                .AutoFilter.ShowAllData
                .Cells(1, 1).CurrentRegion.AutoFilter Field:=4, Criteria1:=Target.Value
                .Activate
            End With
            Cancel = True
        End If
    End Sub
    Please use [CODE]-TAGS
    When your problem is solved mark the thread SOLVED
    If an answer has helped you please click to give reputation
    Read the FORUM RULES

  3. #3
    Registered User
    Join Date
    05-09-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Filter data by double clicking on any cell in range A3:A11 on any worksheet in workboo

    tehneXus,
    Many thanks,
    the code works beautifully.

    RG

+ 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