VBA Decode Hyperlink Not grabbing complete URL

bubbapost

Board Regular
Joined
Mar 11, 2009
Messages
116
Hello,

I'm using the code below to decode a list of hyperlinks in column A however, id doesn't grab the full URL.

All of these links go to different bookmarks within the same website page.

Example:
The full URL is: https://www.ecfr.gov/cgi-bin/text-i...c=true&node=pt42.4.435&rgn=div5#se42.4.435_12
My code only gives me: https://www.ecfr.gov/cgi-bin/text-i...b91d50d51553&mc=true&node=pt42.4.435&rgn=div5

I right click on the link in column A and it has the full URL.

Code:
Sub DecodeEachHyperlink()
Dim hl As Hyperlink
Dim ThisURL As String
For Each hl In ActiveSheet.Hyperlinks
    ThisURL = hl.Address
    hl.Parent.Offset(0, 1).Value = ThisURL
Next hl
End Sub

Can anyone help me please?

Thank you in advance!
Andy
 

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.
Updated example:

The Full URL is: -https://www.ecfr.gov/cgi-bin/text-idx?SID=7cabcefca55c0c40ab13b91d50d51553&mc=true&node=pt42.4.435&rgn=div5#se42.4.435_12-
My code only gives me: -https://www.ecfr.gov/cgi-bin/text-idx?SID=7cabcefca55c0c40ab13b91d50d51553&mc=true&node=pt42.4.435&rgn=div5-
 
Last edited:
Upvote 0
Try one of these:
Code:
        hl.Range.Offset(0, 1).Value = hl.Range.Value
        hl.Range.Offset(0, 2).Value = hl.Address & "#" & hl.SubAddress
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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