Vai al contenuto principale

Come seguire il collegamento ipertestuale al foglio nascosto in Excel?

Ad esempio, ho una cartella di lavoro che contiene più fogli di lavoro, il primo foglio principale ha collegamenti ipertestuali ad altri fogli e ora nascondo tutti i fogli tranne il primo. In questo caso, i collegamenti ipertestuali che collegano a fogli nascosti non sono disponibili. Ma come potresti far funzionare correttamente questi collegamenti ipertestuali? Quando fai clic su un collegamento ipertestuale, il foglio nascosto collegato verrà aperto contemporaneamente come mostrato nella seguente schermata:

collegamento ipertestuale doc al foglio nascosto 1

Segui il collegamento ipertestuale per aprire il foglio nascosto con il codice VBA

Segui il collegamento ipertestuale per aprire il foglio nascosto e nascondilo di nuovo con il codice VBA


Segui il collegamento ipertestuale per aprire il foglio nascosto con il codice VBA

Il seguente codice VBA può aiutarti ad aprire il foglio di lavoro nascosto quando fai clic sul relativo collegamento ipertestuale, per favore fai come segue:

1. Fare clic con il pulsante destro del mouse sulla scheda del foglio che si desidera seguire il collegamento ipertestuale al foglio nascosto, quindi scegliere Visualizza codice dal menu contestuale, nel saltato fuori Microsoft Visual Basic, Applications Edition finestra, copia e incolla il seguente codice nel modulo vuoto:

Codice VBA: segui il collegamento ipertestuale per aprire il foglio nascosto:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Updateby Extendoffice
    Application.ScreenUpdating = False
    On Error Resume Next
    If Target.Column = 1 Then
        Sheets(Target.Value).Visible = xlSheetVisible
        Sheets(Target.Value).Select
    End If
    Application.ScreenUpdating = True
End Sub

collegamento ipertestuale doc al foglio nascosto 2

Note:: Nel codice sopra, il numero 1 in questo Se Target.Column = 1 Then lo script indica il numero di colonna che contiene i collegamenti ipertestuali, per favore cambialo in base alle tue necessità.

2. Quindi salva e chiudi questa finestra di codice, ora, quando fai clic sul collegamento ipertestuale che collega al foglio nascosto specifico, il foglio nascosto verrà aperto immediatamente.


Segui il collegamento ipertestuale per aprire il foglio nascosto e nascondilo di nuovo con il codice VBA

A volte, è necessario seguire il collegamento ipertestuale per aprire il foglio nascosto e quando torni al foglio principale, vuoi che il foglio aperto sia nascosto di nuovo. Il codice VBA sottostante può farti un favore:

1. Fare clic con il pulsante destro del mouse sulla scheda del foglio che si desidera seguire il collegamento ipertestuale al foglio nascosto, quindi scegliere Visualizza codice dal menu contestuale, nel saltato fuori Microsoft Visual Basic, Applications Edition finestra, copia e incolla il seguente codice nel modulo vuoto:

Codice VBA: segui il collegamento ipertestuale per aprire il foglio nascosto quando torni indietro nascondilo di nuovo:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
   'Updateby Extendoffice
    Application.ScreenUpdating = False
    Dim strLinkSheet As String
    If InStr(Target.Parent, "!") > 0 Then
        strLinkSheet = Left(Target.Parent, InStr(1, Target.Parent, "!") - 1)
    Else
        strLinkSheet = Target.Parent
    End If
    Sheets(strLinkSheet).Visible = True
    Sheets(strLinkSheet).Select
    Application.ScreenUpdating = True
End Sub

Private Sub Worksheet_Activate()
    On Error Resume Next
    Sheets(ActiveCell.Value2).Visible = False
End Sub

collegamento ipertestuale doc al foglio nascosto 3

2. Quindi salva annuncio chiudi la finestra del codice, quando fai clic sul collegamento ipertestuale, il foglio nascosto collegato verrà aperto immediatamente, ma, se torni al foglio principale che contiene i collegamenti ipertestuali, il foglio aperto verrà nuovamente nascosto automaticamente.

Note:: Questi codici vengono applicati solo ai nomi dei fogli che corrispondono al testo del collegamento ipertestuale.


Demo: segui il collegamento ipertestuale per aprire il foglio nascosto con il codice VBA

Kutools for Excel: con più di 300 utili componenti aggiuntivi di Excel, liberi di provare senza limitazioni in 30 giorni. Scarica e prova gratuita ora!

I migliori strumenti per la produttività in ufficio

🤖 Assistente AI di Kutools: Rivoluziona l'analisi dei dati basandosi su: Esecuzione intelligente   |  Genera codice  |  Crea formule personalizzate  |  Analizzare i dati e generare grafici  |  Richiama le funzioni di Kutools...
Funzioni popolari: Trova, evidenzia o identifica i duplicati   |  Elimina righe vuote   |  Combina colonne o celle senza perdere dati   |   Round senza formula ...
Super ricerca: VLookup a criteri multipli    VLookup a valori multipli  |   VLookup su più fogli   |   Ricerca fuzzy ....
Elenco a discesa avanzato: Crea rapidamente un elenco a discesa   |  Elenco a discesa dipendente   |  Elenco a discesa a selezione multipla ....
Gestore di colonna: Aggiungi un numero specifico di colonne  |  Sposta colonne  |  Attiva/disattiva lo stato di visibilità delle colonne nascoste  |  Confronta intervalli e colonne ...
Funzionalità in primo piano: Messa a fuoco della griglia   |  Vista di progettazione   |   Grande barra delle formule    Gestore di cartelle di lavoro e fogli   |  Resource Library (Testo automatico)   |  Date picker   |  Combina fogli di lavoro   |  Crittografa/decrittografa le celle    Invia e-mail per elenco   |  Super filtro   |   Filtro speciale (filtro grassetto/corsivo/barrato...) ...
I 15 migliori set di strumenti12 Testo Strumenti (aggiungi testo, Rimuovi personaggi, ...)   |   50+ Grafico Tipi (Diagramma di Gantt, ...)   |   40+ Pratico Formule (Calcola l'età in base al compleanno, ...)   |   19 Inserimento Strumenti (Inserisci il codice QR, Inserisci immagine dal percorso, ...)   |   12 Conversione Strumenti (Numeri in parole, Conversione di valuta, ...)   |   7 Unisci e dividi Strumenti (Combina righe avanzate, Celle divise, ...)   |   ... e altro ancora

Potenzia le tue competenze di Excel con Kutools per Excel e sperimenta l'efficienza come mai prima d'ora. Kutools per Excel offre oltre 300 funzionalità avanzate per aumentare la produttività e risparmiare tempo.  Fai clic qui per ottenere la funzionalità di cui hai più bisogno...

Descrizione


Office Tab porta l'interfaccia a schede in Office e semplifica notevolmente il tuo lavoro

  • Abilita la modifica e la lettura a schede in Word, Excel, PowerPoint, Publisher, Access, Visio e Project.
  • Apri e crea più documenti in nuove schede della stessa finestra, piuttosto che in nuove finestre.
  • Aumenta la produttività del 50% e riduce ogni giorno centinaia di clic del mouse!
Comments (9)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Not sure if I will get a response to this one, but when I click the any of my hyperlinks I get a "reference isn't valid" error.
Everything still works, I just need to click ok to continue.
Does anyone have an idea what causes this error for this code?
Thank you,
This comment was minimized by the moderator on the site
I have created many wordbook and I want to index those in one page.

N.B: My point is I want to hide all the sheets, the sheets will linked with setting picture to main page. By clicking the picture linked sheet will be shown and when I come back to the main sheet the un-hide sheet will be hidden again
This comment was minimized by the moderator on the site
I would like to use this code but only want it to apply to column A. I have other web address links in other cells which cause a problem when running this code.
This comment was minimized by the moderator on the site
My hyperlink "text" is number only, and it doesn't work...
This comment was minimized by the moderator on the site
I'm using the code on two different sheets. It works for one of about 40 hyperlinks on one sheet and it opens two of about 10 hyperlinks one she second, the sheets on the second which do open do go back into hiding when I return to the sheet. The error I get when it will not open a sheet is Run-time error"9": script out of range and the code it points me to - Sheets(strLinkSheet).Visible = True Any ideas as to what change is needed make the code work on all of the sheets? Thank you in advance.
This comment was minimized by the moderator on the site
I have used this code on two different sheets in my workbook, and in both cases it works great, except for the first hyperlink on each page. I get "Subscript out of range error" and the debugger points to the "Sheets(strLinkSheet).Visible = True" right after the "end if". Anyone else see this error? It is only on the first link on the page. (my hyperlinks are in column A, and start in row 2)
This comment was minimized by the moderator on the site
[quote]I have used this code on two different sheets in my workbook, and in both cases it works great, except for the first hyperlink on each page. I get "Subscript out of range error" and the debugger points to the "Sheets(strLinkSheet).Visible = True" right after the "end if". Anyone else see this error? It is only on the first link on the page. (my hyperlinks are in column A, and start in row 2)By HelzBelz[/quote] Sheet names can't have space like "Sheet 1". I fixed my sheet names to "Sheet1" and the error stopped.
This comment was minimized by the moderator on the site
I have a sheet that is hidden that contains a hyperlink. I would like to be able go to the hidden sheet and have it close when I go back to the original sheet. I used the code but it does not work.
This comment was minimized by the moderator on the site
I am trying to hide a sheet that has a hyperlink. I would like to be able to click on the sheet go to the hyperlink sheet and then click back to the sheet and close the hidden sheet. I have tried your instructions but it does not work. Not sure what I am doing wrong.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations