Run macro ONLY if a cell has a Hyperlink?

jmpatrick

Active Member
Joined
Aug 17, 2016
Messages
477
Office Version
  1. 365
Platform
  1. Windows
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:

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

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Maybe something like this?

VBA Code:
If Cells(ActiveCell.row, "L").Value = Hyperlink Then
Call FixAllLinks
Else
End If
 
Upvote 0
Progress!

This works:

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

Forum statistics

Threads
1,214,911
Messages
6,122,192
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top