Vincent88
Active Member
- Joined
- Mar 5, 2021
- Messages
- 382
- Office Version
- 2019
- Platform
- Windows
- Mobile
I tried to have the code to open all URLs from different rows in a column but it only opens all of them in different windows. Only the URL(not listed in the rows) at the end of the script be opened in the same window of the URL listed in the last row. What should be the correct approach to achieve the goal ?
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim lrow As Long
Dim IE As Object
Dim linkcell As Range
lrow = Range("A1").End(xlDown).Row
If Not Selection.Address = "$B$1" Then Exit Sub
Cancel = True
For Each linkcell In Range("E2:E" & lrow)
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate linkcell
While IE.readyState <> 4
DoEvents
Wend
IE.Left = 0
IE.Top = 0
IE.Toolbar = 1
IE.StatusBar = 1
IE.Height = 600
IE.Width = 720
IE.resizable = True '(or False,1 or 0)
Next linkcell
Application.Wait (Now + TimeValue("00:00:03"))
IE.navigate "https://stackoverflow.com/", CLng(2048)
Set IE = Nothing
End Sub