Style lien hypertexte dynamique

Bonjour à tous,

Dans un fichier j'utilise le code suivant pour adapter la couleur de texte suivant l'utilisateur :

Private Sub Worksheet_Change(ByVal Target As Range)
Dim coul, nom, i

coul = Array(3, 10, 5, 26, 46)
nom = Array("test1", "test2", "test3", "test4", "test5")

    If Not Application.Intersect(Target, Range("A:P")) Is Nothing Then

        For i = 0 To UBound(nom)

            If Environ("USERNAME") = nom(i) Then Target.Font.ColorIndex = coul(i)

        Next i

    End If

End Sub

Mais il n'agit pas sur les liens hypertexte. Avec l'enregistreur de macro, j'ai obtenu ceci :

    With ActiveWorkbook.Styles("Hyperlink").Font

        .Underline = xlUnderlineStyleSingle
        .Color = -16776961

    End With

Maintenant je ne vois pas trop comment relier les deux ni si il s'agit de la meilleur manière.

Merci d'avance pour votre aide, ;)

Bonjour SOTIN,

Essaye ceci

Private Sub Worksheet_Change(ByVal Target As Range)
  Dim coul, nom, i
  coul = Array(3, 10, 5, 26, 46)
  nom = Array("test1", "test2", "test3", "test4", "test5")
  If Not Application.Intersect(Target, Range("A:P")) Is Nothing Then
    For i = 0 To UBound(nom)
      If Environ("USERNAME") = nom(i) Then
        Target.Font.ColorIndex = coul(i)
        With ActiveWorkbook.Styles("Hyperlink").Font
          .Underline = xlUnderlineStyleSingle
            .Color = coul(i)
        End With
      End If
    Next i
  End If
End Sub

A+

Bonjour Bruno,

Top merci beaucoup ;)

Au plaisir ;)

Rechercher des sujets similaires à "style lien hypertexte dynamique"