+ Reply to Thread
Results 1 to 6 of 6

Hyperlink click "cell text" to next sheet and auto filter by the "same clicked text" VBA

Hybrid View

  1. #1
    Registered User
    Join Date
    12-23-2019
    Location
    TW
    MS-Off Ver
    2016
    Posts
    4

    Hyperlink click "cell text" to next sheet and auto filter by the "same clicked text" VBA

    Good evening,

    is it possible to have a clicked text hyperlinked to next sheet and auto filter by the same text simultaneously using VBA?

    example, "sheet1"click column B4 brings me to "sheet2 C:C C2 auto filter ", then appear "same result as sheet 1 B4"



    thank you for the help~
    Attached Files Attached Files
    Last edited by determinedtoexceed; 04-26-2021 at 06:31 AM.

  2. #2
    Registered User
    Join Date
    12-23-2019
    Location
    TW
    MS-Off Ver
    2016
    Posts
    4

    Re: Hyperlink click "cell text" to next sheet and auto filter by the "same clicked text" V

    Hi Can anyone help please

    thank you

  3. #3
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: Hyperlink click "cell text" to next sheet and auto filter by the "same clicked text" V

    Try this code in module1
    Sub filter(Item As String)
    '
    '
    Worksheets("2").Activate
    ActiveSheet.AutoFilterMode = False
    ActiveSheet.Range("$A$2:$R$5171").AutoFilter Field:=3, Criteria1:=Item
    End Sub
    And this code in sheet "1"
    Private Sub Worksheet_Change(ByVal Target As Range)
    
    Dim CellAdd As String
    
    If Target.Count > 1 Then Exit Sub
    
    If Not Intersect(Target, Range("B:B")) Is Nothing Then
    Worksheets("2").AutoFilterMode = False
    CellAdd = "$C$" & Application.Match(Target.Value, Worksheets("2").Range("C1:C999"), 0)
    ActiveCell.Offset(-1, 0).Select
    ActiveCell.Hyperlinks.Add Anchor:=ActiveCell, Address:="", SubAddress:="'2'!" & CellAdd, ScreenTip:="", TextToDisplay:=Target.Value
    Call filter(ActiveCell.Value)
    End If
    End Sub
    When you enter an Item Code in column B in sheet "1", it will create a hyperlink to Sheet "2" and filter on the entered item number.

    Is that what you wanted?
    Last edited by Croweater; 04-24-2021 at 09:21 AM.

  4. #4
    Registered User
    Join Date
    12-23-2019
    Location
    TW
    MS-Off Ver
    2016
    Posts
    4

    Re: Hyperlink click "cell text" to next sheet and auto filter by the "same clicked text" V

    Quote Originally Posted by Croweater View Post
    Try this code in module1
    Sub filter(Item As String)
    '
    '
    Worksheets("2").Activate
    ActiveSheet.AutoFilterMode = False
    ActiveSheet.Range("$A$2:$R$5171").AutoFilter Field:=3, Criteria1:=Item
    End Sub
    And this code in sheet "1"
    Private Sub Worksheet_Change(ByVal Target As Range)
    
    Dim CellAdd As String
    
    If Target.Count > 1 Then Exit Sub
    
    If Not Intersect(Target, Range("B:B")) Is Nothing Then
    Worksheets("2").AutoFilterMode = False
    CellAdd = "$C$" & Application.Match(Target.Value, Worksheets("2").Range("C1:C999"), 0)
    ActiveCell.Offset(-1, 0).Select
    ActiveCell.Hyperlinks.Add Anchor:=ActiveCell, Address:="", SubAddress:="'2'!" & CellAdd, ScreenTip:="", TextToDisplay:=Target.Value
    Call filter(ActiveCell.Value)
    End If
    End Sub
    When you enter an Item Code in column B in sheet "1", it will create a hyperlink to Sheet "2" and filter on the entered item number.

    Is that what you wanted?
    Hi Croweater,

    I will have multiple items in row B in "sheet 1",

    i putted codes into designated place and come up with error , unkown name "filter"

    I re-uploaded the xlsm file onto the first post, please assist,

    thank you very much.
    Last edited by determinedtoexceed; 04-25-2021 at 09:41 PM.

  5. #5
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: Hyperlink click "cell text" to next sheet and auto filter by the "same clicked text" V

    Look at the code in your sheet.
    Sub filter()
    
    Sub filter(Item As String)
    
    Worksheets("2").Activate
    ActiveSheet.AutoFilterMode = False
    ActiveSheet.Range("$A$2:$R$5171").AutoFilter Field:=3, Criteria1:=Item
    End Sub
    Can you see how this is different to what I put up?

    Hint: Remove the first line.



    You may also want to try this modification in Sheet1. Not sure how you want it to work.
    Private Sub Worksheet_Change(ByVal Target As Range)
    
    Dim CellAdd As String
    On Error GoTo exitsub
    
        If Target.Count > 1 Then Exit Sub
    
        If Not Intersect(Target, Range("B:B")) Is Nothing Then
            Worksheets("2").AutoFilterMode = False
            CellAdd = "$C$" & Application.Match(Target.Value, Worksheets("2").Range("C1:C999"), 0)
            ActiveCell.Offset(-1, 0).Select
            ActiveCell.Hyperlinks.Add Anchor:=ActiveCell, Address:="", SubAddress:="'2'!" & CellAdd, ScreenTip:="", TextToDisplay:=Target.Value
            Call filter(ActiveCell.Value)
        End If
    
    exitsub:
    End Sub
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        If Not Intersect(Target, Range("B:B")) Is Nothing Then
            If Target.Value = "" Then Exit Sub
            If Target.Hyperlinks.Count > 0 Then
                Call filter(ActiveCell.Value)
            End If
            
        End If
    End Sub
    Last edited by Croweater; 04-26-2021 at 01:21 AM.

  6. #6
    Registered User
    Join Date
    12-23-2019
    Location
    TW
    MS-Off Ver
    2016
    Posts
    4

    Re: Hyperlink click "cell text" to next sheet and auto filter by the "same clicked text" V

    Hi Crowweater,

    I apologize for the mistake, and also i may have lead you to the wrong direction in the early post.

    In the new attachment, i have completed the hyperlinked part [all of column D in "sheet: list" ] to column C in correspondent "sheet: open PO].

    what my goal now is that , for example, when i clicked 0006TW in column D4(sheet:list) , it takes to me to correspondent 0006TW in column C2~C7(sheet:open PO), but only show filter results(sheet:open PO) on the very same name "0006TW "that is clicked, meaning filtering out all other names.

    thank you so much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 4
    Last Post: 06-11-2017, 02:03 PM
  2. Replies: 1
    Last Post: 08-15-2014, 06:00 AM
  3. Using 'Filter(array,"text")' within a macro for lines that begin with "text"
    By Rhudi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-02-2014, 02:22 AM
  4. Replies: 2
    Last Post: 04-20-2014, 11:18 AM
  5. [SOLVED] If there is any text in column "A$" on "sheet1" then move cell to column "A$" on "sheet2"
    By ckgeary in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-27-2013, 08:28 PM
  6. Replies: 2
    Last Post: 08-02-2011, 06:57 AM
  7. How can i copy value from "HTMLText"(EMBED("Forms.HTML:Text","")),using Macro
    By andrewyang in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2010, 12:47 AM

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