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
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Oops missed stuff.
Hold on
 
Last edited:
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top