I have an Excel File with approx 1200 URL’s.
I have a macro that will open these URL’s in single shot , but I realize that this will make system slow and probably might not be possible too.
So I thought to make some changes in script to open URL’s only in selected cells ( lets say 20) , for e.g. if I select Cell A1:A20 and run macro , it should open them in my default browser , once I am done with my operation , I will select next 20 and run macro again.
Here is my Macro, kindly let me know how I can I change to to work only on selected cells
Sub Open_Hyperlinks()
Dim i, LastRow
LastRow = Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To LastRow
If Cells(i, "A").Hyperlinks.Count > 0 Then
Cells(i, "A").Hyperlinks(1).Follow
End If
Next
End Sub
Help is highly appreciated
If your cells are already entered as hyperlinks use this:
Sub Open_SelectedHyperlinks() Dim c As Range If Not TypeOf Selection Is Range Then Exit Sub For Each c In Selection.Cells If c.Hyperlinks.Count > 0 Then _ c.Hyperlinks(1).Follow Next End SubElse, this will follow all cells, even if they are not entered as hyperlinks:
Sub Open_SelectedTextlinks() Dim c As Range If Not TypeOf Selection Is Range Then Exit Sub For Each c In Selection.Cells If c.Hyperlinks.Count = 0 Then ActiveSheet.Hyperlinks.Add Anchor:=c, _ Address:="http://" & c.Value 'Depending on the content of your cell, remove the "http://" & part End If c.Hyperlinks(1).Follow Next End Sub