Need to Display Actual Url Associated With Hyperlink

LionBear

New Member
Joined
Feb 7, 2012
Messages
7
I have a list of 5,000 urls and I'd like to see what the actual url that is returned for each of them. For example, if I run the url www.example.com/runningshoes, that url may redirect to www.example.com/shoes. I'd like to see what each url returns. Is there a formula/macro that I can use to see this? I'm not very experienced in using macros, but I'm willing to give it a shot if it'll work.
 
Last edited:

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
If I'm correct you are wanting to know the the final URL of a hyperlink even if the hyperlink URL is then forwarded/redirected?

You could reference you browsers object library (for Example IE can be referenced through Microsoft Internet Controls)

Code:
Private Sub ReturnFinalURL()
Dim IE As InternetExplorer
Dim URL As String
Dim x As Integer

Set IE = New InternetExplorer

For x = 0 To 9
    'Replace this with your hyperlinks if required
    URL = ThisWorkbook.Sheets("URLs").Range("A1").Offset(x, 0).Value
    IE.Navigate URL
    Do Until IE.ReadyState = READYSTATE_COMPLETE
    Loop
    Debug.Print IE.Document.URL
Next x

IE.Quit

Set IE = Nothing

End Sub

This will no doubt have some problems including if any of your URLs have masked forwarding. My advice would be to look to do this outside of Excel and VBA.
 
Upvote 0

Forum statistics

Threads
1,214,942
Messages
6,122,366
Members
449,080
Latest member
Armadillos

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