existing Hyperlinks does not work

drom

Well-known Member
Joined
Mar 20, 2005
Messages
543
Office Version
  1. 2021
  2. 2019
  3. 2016
  4. 2013
  5. 2011
  6. 2010
  7. 2007
Hi and thanks in advance!

I have a TXT file with some columns and many rows.
One of the columns comes with URL addresses
I have a macro who creates a report for some customers in PDF and shows this URL's as:
  • URL 001
  • URL 002
  • URL 003
And when you click on those places, cells you go to the URL address through internet
This works fine for every client (over 200) except for one

When I click the hyperlink I don't go anywhere.
  • But if I copy the HyperLink address and I paste-it within google chrome and/or internet explorer the URL exists and works fine
I do not know why?

VBA Code:
Dim rcCOL As Range:         Set rcCOL = Range("rcURL") 
  For Each rCell In rcCOL
    If rCell <> "" Then
      X = X + 1
      rCell.Hyperlinks.Add Anchor:=rCell, Address:=rCell, TextToDisplay:="URL " & Format(X, "000")
      'rcRowDataURL.Cells(xRow).Hyperlinks.Add Anchor:=xCell, Address:=xCell.Formula ' aURL(xRow, 1) = ""
    End If
  Next rCell

This are some existing URL's I am not able to make then work using the above code:
URL

This are some existing URL's and working URL's using the above code (the do belong to other customer):
URL


So My problem is why the URL's belonging to my first customer (I have pasted only 2 lines, but is thesame for the other 200 url's, check blue colour ) dont work using the code, and works when doing manually, copy-paste

And for avery other customer the same code always works

Thanks gain!

VBA Code:
Sub WorkingURLeg()
Dim wURL As String: wURL = ActiveCell
    'WORKS
    'wURL = "https://www.netrivals.com/es/redirect-to?re=1&store-redirect-url=YUhSMGNITTZMeTkzeFZiZDNjdVoyOXZaMnhsTG1WekwyRmpiR3MvYzJFOVRDWmhhVDFFUTJoalUwVjNhVmd5YzBNNGNVeHFlVUZvV0doSlN6QkhTR1I1WDBOT01GbEJRa0ZSUjJkS2QyUm5Kbk5wWnoxQlQwUTJORjh4UjBjd1NrOHhVbFpaYUVKRGQyOU1hV2xQZFhSb1YybHpSV2RuSm1OMGVYQmxQVFVtY1QwbWRtVmtQVEJoYUZWTFJYZHBiSFp5TmpoeFRHcDVRV2hZVVVkNlVVbElWRUpXUkZvd1VURnBhMGxNUVNaaFpIVnliRDA9"
    ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=wURL, TextToDisplay:="URL01"
    Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
    
End Sub


VBA Code:
Sub NonWorkingURLeg()
On Error Resume Next        'MANDATORY with this URL's
' Macro4 Macro
Dim wURL As String: wURL = ActiveCell
    'WORKS when copy-Paste on internet but now when using this macro
    'wURL = "https://www.netrivals.com/es/redirect-to?re=1&store-redirect-url=YUhSMGNITTZMeTkzeFZiZDNjdVptRnliV0YyWVhweGRXVjZMbU52YlM5eVpXZGhiRzh0ZG1samFIa3RjSEp2ZEc5amIyeHZMV052Ym5SeVlTMXNiM010WldabFkzUnZjeTFrWlMxc1lTMXlZV1JwWVdOcGIyNHRkV3gwY21GMmFXOXNaWFJoTFRZeE1qQTJNeTVvZEcxcw=="
    'wURL= "https://www.netrivals.com/es/redirect-to?re=1&store-redirect-url=YUhSMGNITTZMeTkzeFZiZDNjdVptRnliV0YyWVhweGRXVjZMbU52YlM5b1pXeHBiMk5oY21VdE16WXdMWGRoZEdWeUxXZGxiQzF6Y0dZMU1DMDFNQzF0YkMwMk1ESTNOekV1YUhSdGJBPT0="
    ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=wURL, TextToDisplay:="URL01"
    Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
    
End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
I can't be certain, but I suspect it may be the case that the URLs (in the case of this one client) are too long. There is apparently a 255 character limit when it comes to a hyperlink URL - see this Post for example. In terms of how to fix it, you can see at the bottom of that post that I proposed one solution, which appears to have been effective. Also, I note that there is the following solution proposed on the Microsoft website: Post I suspect the second option may be better for you, but it will depend.

I hope that helps.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,322
Members
452,635
Latest member
laura12345

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