bossOnothin
New Member
- Joined
- Apr 3, 2021
- Messages
- 3
- Office Version
- 2019
- Platform
- Windows
Hi, I am trying to scrape data from Yahoo Finance, and the code works fine when there is a defined URL. However, when I added a variable, it gives me error 1004. Here is my code:
VBA Code:
Sub macro()
Cells.Clear
ticker = Sheets(1).Cells(1, k)
qurl = "https://finance.yahoo.com/quote/" & ticker & ""
With ActiveSheet.QueryTables.Add(Connection:="URL;" & qurl, Destination:=Range("A27"))
.BackgroundQuery = True
.Refresh BackgroundQuery:=True
End With
End Sub