EXCEL VBA Macro help

ajeanneau

New Member
Joined
Jan 2, 2012
Messages
5
Hi:

I've been trying to write a macro to be able to open multiple hyperlinks all at once. Currently, I have to check thousands of URLs, some of which get removed due to copyright infringement on YouTube. My objective is to be able to track those URLs that have been deleted.

I found the following code:

Sub Open_Hyperlinks()
Dim i, LastRow
LastRow = Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To LastRow
If Cells(i, "A").Hyperlinks.Count > 0 Then
Cells(i, "A").Hyperlinks(1).Follow
End If
Next
End Sub

The problem is that when hyperlinks are removed, the code no longer works. Is it possible to write a code so that it can highlight or change the format on error values?

Thanks!
 
Last edited:

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Here's my suggestion...

Code:
Sub Open_Hyperlinks()
    Dim i, LastRow, status
    On Local Error GoTo Errors
    LastRow = Range("A" & Rows.Count).End(xlUp).Row
    For i = 1 To LastRow
        status = "Testing"
        Select Case Cells(i, "A").Hyperlinks.Count
           Case 0
                status = "No Link"
           Case Else
                Cells(i, "A").Hyperlinks(1).Follow
                If status = "Testing" Then status = "Good"
        End Select
        Cells(i, 2) = status
    Next i
    Exit Sub
Errors:
    status = Err.Description
    Err.Clear
    Resume Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,111
Messages
6,128,898
Members
449,477
Latest member
panjongshing

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