Bonjour,
Je pense que l'adaptation ci-dessous devrait convenir. Dans l'ordre :
Si elle contient un lien : ne fait rien
Si elle commence par "https://" : ajout d'un lien
Si elle contient quelque chose qui ne commence par par https :
- si la cellule est vide : ne fait rien
- sinon : cellule en rouge
Sub HyperlinkConverter()
Dim xCell As Range
For Each xCell In Range("E22:E10000")
If xCell.Hyperlinks.Count = 0 Then
If Left$(xCell.Value2, Len("https://")) = "https://" Then
ActiveSheet.Hyperlinks.Add _
Anchor:=xCell, _
Address:=xCell.Value2, _
TextToDisplay:="URL-LOCATION"
Else
If xCell.Value2 <> vbNullString Then xCell.Font.Color = RGB(255, 0, 0)
End If
End If
Next xCell
End Sub
Ah je viens de relire votre message, pour vérifier les liens déjà existant il faut supprimer la première vérification. Soit
Sub HyperlinkConverter()
Dim xCell As Range
For Each xCell In Range("E22:E10000")
If Left$(xCell.Value2, Len("https://")) = "https://" Then
ActiveSheet.Hyperlinks.Add _
Anchor:=xCell, _
Address:=xCell.Value2, _
TextToDisplay:="URL-LOCATION"
Else
If xCell.Value2 <> vbNullString Then xCell.Font.Color = RGB(255, 0, 0)
End If
Next xCell
End Sub