Ir para o conteúdo principal

Como seguir um hiperlink para uma planilha oculta no Excel?

Por exemplo, eu tenho uma pasta de trabalho que contém várias planilhas, a primeira planilha mestre tem hiperlinks para outras planilhas e agora, oculto todas as planilhas, exceto a primeira. Nesse caso, os hiperlinks vinculados a planilhas ocultas não estão disponíveis. Mas, como você poderia fazer esses hiperlinks funcionarem com sucesso? Quando você clica em um hiperlink, a página oculta vinculada é aberta de uma só vez, conforme mostrado a seguir:

hiperlink de doc para folha oculta 1

Siga o hiperlink para abrir a página oculta com o código VBA

Siga o hiperlink para abrir a folha oculta e, em seguida, esconda-a novamente com o código VBA


Siga o hiperlink para abrir a página oculta com o código VBA

O código VBA a seguir pode ajudá-lo a abrir a planilha oculta ao clicar em seu hiperlink relativo, faça o seguinte:

1. Clique com o botão direito na guia da planilha que você deseja seguir o hiperlink para a planilha oculta e escolha Ver código a partir do menu de contexto, no pop-out Microsoft Visual Basic para Aplicações janela, copie e cole o seguinte código no módulo em branco:

Código VBA: siga o hiperlink para abrir a planilha oculta:

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

hiperlink de doc para folha oculta 2

Note: No código acima, o número 1 neste Se Target.Column = 1 Then script indica o número da coluna que contém os hiperlinks, altere-o conforme sua necessidade.

2. Em seguida, salve e feche esta janela de código, agora, ao clicar no hiperlink que vincula à folha oculta específica, a folha oculta será aberta imediatamente.


Siga o hiperlink para abrir a folha oculta e, em seguida, esconda-a novamente com o código VBA

Às vezes, você precisa seguir o hiperlink para abrir a planilha oculta e, ao voltar para a planilha mestre, deseja que a planilha aberta fique oculta novamente. O código VBA abaixo pode lhe fazer um favor:

1. Clique com o botão direito na guia da planilha que você deseja seguir o hiperlink para a planilha oculta e escolha Ver código a partir do menu de contexto, no pop-out Microsoft Visual Basic para Aplicações janela, copie e cole o seguinte código no módulo em branco:

Código VBA: siga o hiperlink para abrir a página oculta quando voltar e ocultá-la novamente:

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

hiperlink de doc para folha oculta 3

2. Em seguida, salve o anúncio e feche a janela de código, ao clicar no hiperlink, a planilha oculta vinculada será aberta imediatamente, mas, se você voltar à planilha mestre que contém os hiperlinks, a planilha aberta será ocultada automaticamente novamente.

Note: Esses códigos são aplicados apenas aos nomes das planilhas que correspondem ao texto do hiperlink.


Demonstração: siga o hiperlink para abrir a folha oculta com o código VBA

Kutools for Excel: com mais de 300 suplementos úteis do Excel, grátis para testar sem limitação em 30 dias. Baixe e teste grátis agora!

Melhores ferramentas de produtividade de escritório

🤖 Assistente de IA do Kutools: Revolucionar a análise de dados com base em: Execução Inteligente   |  Gerar Código  |  Crie fórmulas personalizadas  |  Analise dados e gere gráficos  |  Invocar funções do Kutools...
Recursos mais comuns: Encontre, destaque ou identifique duplicatas   |  Excluir linhas em branco   |  Combine colunas ou células sem perder dados   |   Rodada sem Fórmula ...
Super pesquisa: VLookup de múltiplos critérios    VLookup de múltiplos valores  |   VLookup em várias planilhas   |   Pesquisa Difusa ....
Lista suspensa avançada: Crie rapidamente uma lista suspensa   |  Lista suspensa de dependentes   |  Lista suspensa de seleção múltipla ....
Gerenciador de colunas: Adicione um número específico de colunas  |  Mover colunas  |  Alternar status de visibilidade de colunas ocultas  |  Compare intervalos e colunas ...
Recursos em destaque: Foco da Grade   |  Vista de Design   |   Grande Barra de Fórmula    Gerenciador de pastas de trabalho e planilhas   |  Biblioteca (Auto texto)   |  Data Picker   |  Combinar planilhas   |  Criptografar/Descriptografar Células    Enviar e-mails por lista   |  Super Filtro   |   Filtro Especial (filtro negrito/itálico/tachado...) ...
15 principais conjuntos de ferramentas12 Texto Ferramentas (Adicionar texto, Remover Personagens, ...)   |   50+ de cores Tipos (Gráfico de Gantt, ...)   |   Mais de 40 práticos Fórmulas (Calcule a idade com base no aniversário, ...)   |   19 Inclusão Ferramentas (Insira o código QR, Inserir imagem do caminho, ...)   |   12 Conversão Ferramentas (Números para Palavras, Conversão de moedas, ...)   |   7 Unir e dividir Ferramentas (Combinar linhas avançadas, Dividir células, ...)   |   ... e mais

Aprimore suas habilidades de Excel com o Kutools para Excel e experimente uma eficiência como nunca antes. Kutools para Excel oferece mais de 300 recursos avançados para aumentar a produtividade e economizar tempo.  Clique aqui para obter o recurso que você mais precisa...

Descrição


Office Tab traz interface com guias para o Office e torna seu trabalho muito mais fácil

  • Habilite a edição e leitura com guias em Word, Excel, PowerPoint, Publisher, Access, Visio e Project.
  • Abra e crie vários documentos em novas guias da mesma janela, em vez de em novas janelas.
  • Aumenta sua produtividade em 50% e reduz centenas de cliques do mouse para você todos os dias!
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