VBA Code Stopped Working

purceld2

Well-known Member
Joined
Aug 18, 2005
Messages
586
Office Version
  1. 2013
Platform
  1. Windows
The VBA code below has been working fine no issues and today it stopped working I have tried everything can cannot get it to work.

Basically I select a range of hyperlinks and it then goes to Chrome and opens a tab

VBA Code:
Sub OpenHyperLinks()
'Update 20141124
    Dim xHyperlink As Hyperlink
    Dim WorkRng As Range
    On Error Resume Next
    xTitleId = "KutoolsforExcel"
    Set WorkRng = Application.Selection
    Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
    For Each xHyperlink In WorkRng.Hyperlinks
        xHyperlink.Follow
    Next
End Sub

Just to add If I clink on a single Hyperlink it opens the Youtube as expected but when using the above VBA code it display the box with the range and when ok clicked it does nothing.

Thank you in advance for any help

Rare grooves & modern soul flavours Listing REMOVED This One.xlsm
AB
1Title Link
2Mirage - There Is A Love For Everyone (1978) LPPrincess Of Love RCA Victorhttps://www.youtube.com/results?search_query=Mirage+-+There+Is+A+Love+For+Everyone+(1978)+LPPrincess+Of+Love++RCA+Victor
3The Stylistics - Smooth (1978) LPIn Fashion Mercuryhttps://www.youtube.com/results?search_query=The+Stylistics+-+Smooth+(1978)+LPIn+Fashion++Mercury
4Rockie Robbins - Girl I’m Gonna Get You (1980) LPYou And Me A&Mhttps://www.youtube.com/results?search_query=Rockie+Robbins+-+Girl+I’m+Gonna+Get+You+(1980)+LPYou+And+Me++A%26M
5Oscar Perry - Playboy Side Of Town (1978) LPMoods Of The Man Crazy Cajunhttps://www.youtube.com/results?search_query=Oscar+Perry+-+Playboy+Side+Of+Town+(1978)+LPMoods+Of+The+Man++Crazy+Cajun
6Gloria Covington - Sweet Love Affair (1980) LPMovin' On Casablancahttps://www.youtube.com/results?search_query=Gloria+Covington+-+Sweet+Love+Affair+(1980)+LPMovin'+On++Casablanca
7Intrepids - After You’ve Had Your Fling (Get Down To The Real Thing) (1975) Columbiahttps://www.youtube.com/results?search_query=Intrepids+-+After+You’ve+Had+Your+Fling+(Get+Down+To+The+Real+Thing)+(1975)++Columbia
8Willie Fisher - Put Your Lovin’ On Me (1975) Tigresshttps://www.youtube.com/results?search_query=Willie+Fisher+-+Put+Your+Lovin’+On+Me+(1975)++Tigress
9Garland Green - Let Me Be Your Pacifier (1977) LPLove Is What We Came Here For Unihttps://www.youtube.com/results?search_query=Garland+Green+-+Let+Me+Be+Your+Pacifier+(1977)+LPLove+Is+What+We+Came+Here+For++Uni
10Millie Jackson - You Can’t Stand The Thought Of Another Me (1975) LPStill Caught Up Polydorhttps://www.youtube.com/results?search_query=Millie+Jackson+-+You+Can’t+Stand+The+Thought+Of+Another+Me+(1975)+LPStill+Caught+Up++Polydor
11Carolyn Franklin - You Can Have My Soul (1976) LPIf You Want Me RCA Victorhttps://www.youtube.com/results?search_query=Carolyn+Franklin+-+You+Can+Have+My+Soul+(1976)+LPIf+You+Want+Me++RCA+Victor
123rd Flight - Love Love Love (1972) Yodihttps://www.youtube.com/results?search_query=3rd+Flight+-+Love+Love+Love+(1972)++Yodi
13Rare Function - Baby I’m For Real (1976) Soul Unlimitedhttps://www.youtube.com/results?search_query=Rare+Function+-+Baby+I’m+For+Real+(1976)++Soul+Unlimited
14Milton Floyd - I’m A Shadow (1973) Rimhttps://www.youtube.com/results?search_query=Milton+Floyd+-+I’m+A+Shadow+(1973)++Rim
15Linda Jones - Not On The Outside (1972) Turbohttps://www.youtube.com/results?search_query=Linda+Jones+-+Not+On+The+Outside+(1972)++Turbo
16Billy Cee - Don’t Matter To Me (1974) GSEhttps://www.youtube.com/results?search_query=Billy+Cee+-+Don’t+Matter+To+Me+(1974)++GSE
17The Two Things In One - Together Forever (1973) Music Cityhttps://www.youtube.com/results?search_query=The+Two+Things+In+One+-+Together+Forever+(1973)++Music+City
18Dorando - Didn’t I (1972) Music Cityhttps://www.youtube.com/results?search_query=Dorando+-+Didn’t+I+(1972)++Music+City
19Side Effect - Spend It On Love (1973) LPEffective Passion Music Ltdhttps://www.youtube.com/results?search_query=Side+Effect+-+Spend+It+On+Love+(1973)+LPEffective++Passion+Music+Ltd
20Strutt - Said You Didn’t Love Him (1976) LPTime Moves On Brunswickhttps://www.youtube.com/results?search_query=Strutt+-+Said+You+Didn’t+Love+Him+(1976)+LPTime+Moves+On++Brunswick
21The Voices Of East Harlem - Take A Stand (1974) LPCan You Feel It Just Sunshinehttps://www.youtube.com/results?search_query=The+Voices+Of+East+Harlem+-+Take+A+Stand+(1974)+LPCan+You+Feel+It++Just+Sunshine
List of Music
Cell Formulas
RangeFormula
B2:B21B2=HYPERLINK(CONCATENATE("https://www.youtube.com/results?search_query=",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2," ","+"),"&","%26"),"[","%5B"),":","%3A"),"]","%5D")))
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Firstly thank you for providing some valid Test Data, it makes a huge difference in us being able to help you.

A solution to this was posted by @lrobbo314 in March 2020 here and which I have used to modify your code below:
HYPERLINK() function not working with VBA .Follow
Although the OP in that case seemed to still have some issues with it, it works fine on your data.

Your revised code looks like the below:
VBA was not recognising the formula generated hyperlinks as a hyperlinks and Selection.Hyperlinks.count returned 0.

VBA Code:
Sub OpenHyperLinks_Mod()
'Update 20141124
    Dim xHyperlink As Hyperlink     ' Not required
    Dim WorkRng As Range
    Dim xTitleId As String
    On Error Resume Next
    xTitleId = "KutoolsforExcel"
    Set WorkRng = Application.Selection
    Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
    
    ' Courtesy of lrobbo314 13/03/2020
    Dim rCell As Range
    For Each rCell In WorkRng.Cells
        ActiveWorkbook.FollowHyperlink rCell.Value
    Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,628
Messages
6,173,429
Members
452,514
Latest member
cjkelly15

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