How to download IE csv direct to excel

jonathanwang003

Board Regular
Joined
May 9, 2014
Messages
123
Hi All,

My macro below worked until today. I have a URL that used to open and paste right into excel. Not sure why this broke. Is there another method I could use to download the qurl into Excel? When I paste the qurl into IE, it opens up the CSV so it appears the qurl is still valid.

VBA Code:
Sub TestDownload()
Dim qurl as string
qurl = "https://query1.finance.yahoo.com/v7/finance/download/^GSPC?period1=1544400000&period2=1583366400&interval=1d&events=history&crumb=nfhoFBTOnvj"

With ActiveSheet.QueryTables.Add(Connection:="URL;" & qurl, Destination:=Range("A1")
            .PostText = True
            .SaveData = True
            .Refresh BackgroundQuery:=False
    End With
End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
{"finance":{"result":null,"error":{"code":"Unauthorized","description":"Invalid Crumb"}}}
maybe you need authorization or key
 
Upvote 0
I got exactly the same error
but you can try via Power Query (Get&Transform)
Ctrl, A, PN, O, W
 
Upvote 0
Hi All,

So I've been testing the validity of the URL and researching power query. Not sure how to incorporate power query into this but I did confirm the URL works... so it seems like the crumb is unique to each user. What I did confirm is that how the URL is constructed is consistent so I can still use the URL above to test.

I suspect yahoo must have changed something on their end. The URL construct is from the following URL, right clicking on the "Download Data" and selecting "Copy Link Location"


If you download this attachment, it should generate a unique "crumb" that would work for each specific user. Is it possible to use VBA to pull this csv into excel?
 
Upvote 0
you can use url you posted and you will get the same (I think) data as in csv from Table2

mft.png
 
Upvote 0
Sandy, were you able to pull that screenshot from the power query method? This is what I got when I tried. Not sure how to overcome this.

1583713937768.png
 
Upvote 0
https://finance.yahoo.com/quote/MSFT/history?p=MSFT
and method from post#4
then select Table2
Edit

there should be Alt not Ctrl, sorry

like: Alt A, PN, O, W
 
Upvote 0
Got it. Yes I am able to get that url to work too. The challenge is that I modify the date range (ie 500 days) which won't show on screen, but is in the "download data" link.

1583714375045.png

I was previously able to use the link to the download to import to csv, but now come across an error. It's strange that I can construct the url for that link location but it just doesn't seem to work with VBA trying to retrieve it.
 
Upvote 0
you can still download csv but you cannot use this link directly to excel (Authentication failure)
ask yahoo why

I'm against vba so I can't help , sorry
have a nice day
 
Upvote 0

Forum statistics

Threads
1,215,686
Messages
6,126,202
Members
449,298
Latest member
Jest

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