Can somebody help me with a VBA code for extracting data from Yahoo Finance?
Thanks!
Can somebody help me with a VBA code for extracting data from Yahoo Finance?
Thanks!
It would help if you posted the Url for the site
viorelmusca
I went to Yahoo as per your URL, Made an equiry usinh yhoo as the symbol code
After the data was displayed I copied the URL
I then recorded this macro whilst I took the following actions
Data Menu > Import External Data > New Web Query
Paste URL into address
Go Button
Import button
Follow the rest of the prompts
You will need to change the yhoo code in the macro for what ever code you require
Sub Macro2()
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://finance.yahoo.com/q?s=yhoo", Destination:=Range("A1"))
.Name = "q?s=yhoo"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = False
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
Super! It's working..!! for yahoo ...
i tryed this url:
http://www.bvb.ro/cgi-bin/delayed/vi...elect_leng=ENG
and is saying that there is no data ... (????)
can you help me with this? or can you explain me why it isn't working ...??
thanks!
Viorel
Viorel
The URL appears to be incomplete.
I am not sure if I found what you are after.
This Url is for data found by folling the links under Monitering Tools > Delayed Info (Equuity Trade).
Try replacing your Url with this one
"URL;http://www.bvb.ro/cgi-bin/delayed/viewip.cgi?cmb=26368238636&select_leng=ENG&select_usercode=basic&select_usertype=basic&test=014258',5)"
If this is not what you are after please post instructions how I get to the data page that you require.
Yes, that' what I want.
I used the url that you give me, but I get the same msg:
"File cannot be opened because: a string literal was expacted, but no opening quote character was found. Line 6, Position 46"I don't know what this meens... Do you??
.... Is there a chance to get that data???![]()
Viorel
I don't know why you are having problems
It works ok for me - I have wrapped the URL code incase that is causing the problem for you
Sub Macro2()
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.bvb.ro/cgi-bin/delayed/viewip.cgi?cmb=" _
& "26368238636&select_leng=ENG&select_usercode=" _
& "basic&select_usertype=basic&test=014258',5)", _
Destination:=Range("A1"))
.Name = "q?s=yhoo"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = False
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
mudraker
Do you have Office XP or 2003? I have Office XP. Do you think this may be the problem?
I also used the macro you post, but it's giving me the same error msg.
Can you please attach the worksheet?
Thank you
Viorel
I am using 2003
I have attached a workbook that I created this morning by coping & pasting my code from my last reply and then running the macro.
I do not know what the VBA code difference is between XP & 2003
Have you tried recording a macro whilst you go through the steps of importing the data via a new web query
then recorded this macro whilst I took the following actions
Data Menu > Import External Data > New Web Query
Paste URL into address
Go Button
Import button
Follow the rest of the prompts
Use the folling URL
http://www.bvb.ro/cgi-bin/delayed/viewip.cgi?cmb=26368238636&select_leng=ENG&select_usercode=basic&select_usertype=basic&test=014258',5)
Try the above steps then post your recorded code & I will look at it
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks