Excel Follow Hyperlinks with VBA problem

RCVFX

New Member
Joined
Jun 25, 2019
Messages
1
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
 

Some videos you may like

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
40,791
Office Version
365
Platform
Windows
Oops missed stuff.
Hold on
 
Last edited:

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
40,791
Office Version
365
Platform
Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,099,246
Messages
5,467,504
Members
406,543
Latest member
margram

This Week's Hot Topics

Top