问题
I want to open all the hyperlinks in a column at once,
code i used is
Sub OpenLinks()
Dim HL As Hyperlink
For Each HL In Selection.Hyperlinks
HL.Follow
Next
End Sub
this macro works fine when i select the cell containing www.google.com but dont work when I select cell next to it and run the macro
i have created the links mentioned in green and red column using the formula from this question https://stackoverflow.com/a/65867184/14713550
edit
回答1:
I think you are looking something below. Follow-up from my previous answer for VBA
macro you need to convert all text to a valid URL. Here output from Hyperlink()
will not work while direct hyperlink to the cell will work. There is big difference between hyperlink to cell and formula to the cell. So, using some VBA functions you have to concatenate all text to a single string then launch that hyperlink using ActiveSheet.FollowHyperlink
or ThisWorkBook.FollowHyperlink
method. Give a try on my below sub then let me know your feedback.
Sub OpenMyLink()
Dim strURL As String, fixedURL As String
Dim rng As Range
fixedURL = "https://in.tradingview.com/chart/?symbol=NSE:"
For Each rng In Selection
strURL = fixedURL & Replace(Replace(rng, "&", "_", 1, 1), "-", "_", 1, 1) & "1!"
ThisWorkbook.FollowHyperlink strURL
Next rng
End Sub
来源:https://stackoverflow.com/questions/65879870/open-all-hyperlinks-from-selected-column-at-once-in-excel