Skip to content

Instantly share code, notes, and snippets.

@WinXaito
Created October 14, 2020 09:45
Show Gist options
  • Save WinXaito/c3445f685eb2fa09c3514ef78534e5a6 to your computer and use it in GitHub Desktop.
Save WinXaito/c3445f685eb2fa09c3514ef78534e5a6 to your computer and use it in GitHub Desktop.
Parcours des liens (Macro VBA Excel)
Sub ParcoursHyperlien()
' Initialisation variable
Dim startRow As Integer
Dim column As Integer
Dim row As Integer
Dim val As String
Dim hp As Hyperlink
Dim hpCount As Integer
Dim hpRange As range
Dim hpIndex As Integer
' Paramètre
startRow = 1
column = 1
' Parcours de la colonne
row = startRow
Do
' On récupère la cellule
Set hpRange = range(Cells(row, column), Cells(row, column))
' On compte le nombre de lien dans la cellule
hpCount = hpRange.Hyperlinks.Count
val = hpRange.Value2
' .. Si la cellule contient des liens
If hpCount > 0 Then
' On parcours les liens de la cellule
For hpIndex = 1 To hpCount
' On récupère le lien et ses infos
Set hp = hpRange.Hyperlinks(hpIndex)
Debug.Print "===================="
Debug.Print "Address: " & hp.Address
Debug.Print "Application: " & hp.Application
Debug.Print "Name: " & hp.Name
Debug.Print "TextToDisplay: " & hp.TextToDisplay
Next hpIndex
End If
' On passe à la ligne suivante
row = row + 1
Loop While val <> ""
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment