Macro failing to open all of my links in excel

squeakums

Well-known Member
Joined
May 15, 2007
Messages
823
Office Version
  1. 365
So, I created an excel document that created hyper links to each site I pull from. I created a macro that clicks on those links and opens each one. My macro often fails to open all of them for some odd reason? The macro clicks on each cell and opens the hyperlink. Sometimes it opens a few more than the first run. Is there a way around this where I can have it open all of my hyperlinks? I checked the cells, click on the hyperlinks and they work if I do it manually, and they are all in the B cells. A little nerve racking.

Range("B13").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
Windows("test.xlsm").Activate
Range("B11").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
Windows("test.xlsm").Activate
Range("B3").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
Windows("test.xlsm").Activate
Range("B4").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
Windows("test.xlsm").Activate
Range("B5").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
Windows("test.xlsm").Activate
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
try FollowHyperlink Address method

VBA Code:
ActiveWorkbook.FollowHyperlink Address:=ActiveSheet.Range("B13").value
 
Upvote 0
Causes an unexpected error and requires a debug. This brings up would you like to open a file, it might have a virus; its just a thing with my company, I always hit yes that's fine, or yes and it goes with the other code but it debugs with this code.
 
Upvote 0
where are you running the code from, whats the error that pops up and what is the line it is highlighting when you hit "debug"?
the only thing i could think as to why that isnt working is the text is different than the hyperlink? or you arent running the code in the same workbook or the same sheet.
 
Upvote 0
It was because one of the links was opening an visual studio and then the web hyperlinks. I changed the order in my original code and it seemed to fix the issue.
 
Upvote 0
awesome.
you can also use this code to open any hyperlinks in column B
VBA Code:
Sub HLtest()
Dim ws As Worksheet
Set ws = ActiveSheet

For Each lnk In ws.Range("B:B").Hyperlinks
ActiveWorkbook.FollowHyperlink lnk.Address
Next lnk
 
End Sub

just in case the text value of the cell is different than the link itself
 
Upvote 0

Forum statistics

Threads
1,214,998
Messages
6,122,639
Members
449,093
Latest member
Ahmad123098

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