PC Review


Reply
Thread Tools Rate Thread

Code to get data from Yahoo Finance

 
 
TEB2
Guest
Posts: n/a
 
      4th Nov 2008
If I paste the following code in the address bar in IE, I get a window asking
me if I want to open or save a csv file which has the monthly highs for the
stock for the time period specified:

http://ichart.finance.yahoo.com/table.csv?s=(insert stock
symbol)&a=12&b=01&c=2007&d=01&e=01&f=2009&g=m&ignore=.csv

Here's the issue. I have a list of 332 stock symbols in a spreadsheet. I
need the code that will insert the first stock symbol after "s=" in the above
address, save the file to a specific folder and loop thru the list till the
end.

I have to evaluate these stocks on a monthly basis to determine the
market-to-cost adjustment. This would be my final piece to fully automate
the process.

Thanks for your help!

Tom
 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      4th Nov 2008

If you send ME your email address I will send you a file of mine that does
this for you. All you do is input the symbol . Or, send me your file and
I'll take a look.
Symbol Name Basis
Shares Last Trade Value Profit
IBM INTL BUSINESS MAC $ 100.00 100.00 $
90.86 $ 9,086.00 $ 8,986.00
T AT&T INC. $ 100.00 100.00 $ 26.21 $
2,621.00 $ 2,521.00
MSFT MICROSOFT CP - $ 24.12
-
FE FIRSTENERGY CP - $ 52.74
-
cm-pd.to CANADIAN IMP BANK - $ 20.19
$ -
^GSPC S&P 500 INDEX,RTH - $ 963.20
-


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"TEB2" <(E-Mail Removed)> wrote in message
news:17B1B371-17CC-4413-A208-(E-Mail Removed)...
> If I paste the following code in the address bar in IE, I get a window
> asking
> me if I want to open or save a csv file which has the monthly highs for
> the
> stock for the time period specified:
>
> http://ichart.finance.yahoo.com/table.csv?s=(insert stock
> symbol)&a=12&b=01&c=2007&d=01&e=01&f=2009&g=m&ignore=.csv
>
> Here's the issue. I have a list of 332 stock symbols in a spreadsheet. I
> need the code that will insert the first stock symbol after "s=" in the
> above
> address, save the file to a specific folder and loop thru the list till
> the
> end.
>
> I have to evaluate these stocks on a monthly basis to determine the
> market-to-cost adjustment. This would be my final piece to fully automate
> the process.
>
> Thanks for your help!
>
> Tom


 
Reply With Quote
 
Charles L. Snyder
Guest
Posts: n/a
 
      4th Nov 2008

This retired EE Prof has hundreds of excel spreadsheets, all freely
downloadable, that will do what you want and more:

http://www.gummy-stuff.org/

cls
 
Reply With Quote
 
Joel
Guest
Posts: n/a
 
      5th Nov 2008
Can anybody tell me why I can't get the sendkey to work in this code. I put
the Stock symbol in the Active worksheet in cell A1. I just can't get the
file saved properly.


Sub GetStocks()
Const READYSTATE_LOADING = 1
Folder = "c:\Temp\"
URL1 = "http://ichart.finance.yahoo.com/table.csv?s="
URL2 = "&a=12&b=01&c=2007&d=01&e=01&f=2009&g=m&ignore=.csv"

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True

RowCount = 1
Do While Range("A" & RowCount) <> ""
Stock = Range("A" & RowCount)
On Error Resume Next
Kill (Folder & Stock & ".csv")
On Error GoTo 0
'get web page
IE.Navigate2 URL1 & Stock & URL2
Do While IE.readystate <> READYSTATE_LOADING
DoEvents
Loop

'Loop
Application.Wait (Now + TimeValue("0:00:05"))
AppActivate "File Download", True

'Alt S - Save File
Application.SendKeys "%S", True
'Alt n - Enter filename
Application.SendKeys "%n", True
Application.SendKeys _
(Folder & Stock & ".csv{ENTER}"), True



RowCount = RowCount + 1
Loop


End Sub

"Charles L. Snyder" wrote:

>
> This retired EE Prof has hundreds of excel spreadsheets, all freely
> downloadable, that will do what you want and more:
>
> http://www.gummy-stuff.org/
>
> cls
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Import Historical Stock Data from Yahoo-Finance ryguy7272 Microsoft Access VBA Modules 1 23rd Jul 2011 11:58 PM
Computer Hardware In France Report Contains An Executive Summary And Data On Value, Volume And Segmentation (Business Wire via Yahoo! Finance) info@neobasic.biz Computer Hardware 0 10th Feb 2007 06:02 AM
finance.yahoo historical data tinybears Microsoft Excel Discussion 0 21st Apr 2006 06:35 PM
importing/ analyzing Yahoo!Finance stock data Paul987 Microsoft Excel Worksheet Functions 0 17th Mar 2006 04:18 PM
Downloading .csv Data from Yahoo Finance into Excel =?Utf-8?B?Zm91cnN0YXI3Nw==?= Windows XP Internet Explorer 2 17th Feb 2004 01:57 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:03 PM.