Results 1 to 3 of 3

Thread: Excel Follow Hyperlinks with VBA problem
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Jun 2019
    Posts
    1
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Excel Follow Hyperlinks with VBA problem

    Hello guys,
    I'm new to this forum and I wanted to say that English is not my native language, so if I make some mistakes, please forgive me.
    I'm trying to create a fitness related Excel "software" but I have some problems with hyperlinks.

    In the workbook I have one main tab (named "Intro") witch contains links to multible hidden sheets. There's also, in the Intro tab, a question asked to the user that will define one hyperlink destination. If the answer given (cell M15) is "Yes", the hyperlink in cell C20 will bring me to the hidden sheet "DatiClienti_SiBIA", otherwise the hyperlink in cell C20 will bring me to the hidden sheet "DatiClienti_NoBIA". I've been able to do this with VBA by using this code in the intro tab:

    Code:
    Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
        
        If [M15] = "SI" Then
        
        Application.ScreenUpdating = False
        Worksheets("DatiCliente_SiBIA").Visible = xlSheetVisible
        Sheets("DatiCliente_SiBIA").Visible = True
        Sheets("DatiCliente_SiBIA").Select
        
        ElseIf [M15] = "NO" Then
        
        Application.ScreenUpdating = False
        Worksheets("DatiCliente_NoBIA").Visible = xlSheetVisible
        Sheets("DatiCliente_NoBIA").Visible = True
        Sheets("DatiCliente_NoBIA").Select
        
        Else
        MsgBox ("Selezionare se verrą effettuata o meno l'analisi BIA")
        End If
        
        Application.ScreenUpdating = True
        
    
    End Sub
    There's one problem though. I have multiple Hyperlinks in the Intro page, in various cells and whenever I click one of them, Excel will always use the vba code and bring me to either "DatiCliente_NoBIA" or "DatiCliente_SiBIA".

    How can I fix this issue?

    Thanks for you attention.
    RCVFX

  2. #2
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    24,132
    Post Thanks / Like
    Mentioned
    411 Post(s)
    Tagged
    43 Thread(s)

    Default Re: Excel Follow Hyperlinks with VBA problem

    Oops missed stuff.
    Hold on
    Last edited by Fluff; Jun 25th, 2019 at 09:50 AM.
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  3. #3
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    24,132
    Post Thanks / Like
    Mentioned
    411 Post(s)
    Tagged
    43 Thread(s)

    Default Re: Excel Follow Hyperlinks with VBA problem

    Hi & welcome to MrExcel.
    How about
    Code:
    Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
       Dim Lnk As String, Sht As String
       
       If Target.Parent.Address(0, 0) <> "C20" Then
          Lnk = Target.SubAddress
          If InStr(1, Lnk, "!") > 0 Then
             Sht = Replace(Left(Lnk, InStr(1, Lnk, "!") - 1), "'", "")
             Sheets(Sht).Visible = True
             Sheets(Sht).Activate
          End If
       Else
       
       
          If [M15] = "SI" Then
          
          Application.ScreenUpdating = False
          Worksheets("DatiCliente_SiBIA").Visible = xlSheetVisible
          Sheets("DatiCliente_SiBIA").Visible = True
          Sheets("DatiCliente_SiBIA").Select
          
          ElseIf [M15] = "NO" Then
          
          Application.ScreenUpdating = False
          Worksheets("DatiCliente_NoBIA").Visible = xlSheetVisible
          Sheets("DatiCliente_NoBIA").Visible = True
          Sheets("DatiCliente_NoBIA").Select
          
          Else
          MsgBox ("Selezionare se verrą effettuata o meno l'analisi BIA")
          End If
       End If
       Application.ScreenUpdating = True
       
    
    End Sub
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •