# Run macro ONLY if a cell has a Hyperlink?



## jmpatrick (Dec 19, 2022)

Good morning and Happy Holidays!

I have a macro that "repairs" or relinks hyperlinks based on text in the cell.  I can't figure out how to have the code run ONLY on cells which already contain a hyperlink.  As is now the script just blasts away creating a new hyperlink whether or not one already exists.  I want it to determine if the cell has a link and if it does do it's thing, otherwise it should leave the cell alone.

Here's how I create hyperlinks:


```
.Hyperlinks.Add Anchor:=newRange, _
      Address:=Sheets("Hyperlinks").Range("I1"), TextToDisplay:=ActiveCell.Text
      End With
```


----------



## jmpatrick (Dec 19, 2022)

Maybe something like this?


```
If Cells(ActiveCell.row, "L").Value = Hyperlink Then
Call FixAllLinks
Else
End If
```


----------



## jmpatrick (Dec 19, 2022)

Progress!

This works:

If Cells(ActiveCell.Row, "L").Hyperlinks.Count > 0 Then
Call FixAllLinks
Else
End If


----------

