Need help in getting data

vssoma

Well-Known Member
#1
dear,
i am trying to build( practicing VBA) a sheet which downloads two stocks data from yahoo.
pls find the sheet below as attached.

http://ww w. 4 shared . com/ file/ PWgLsj1lba/ try-2014.html

( remove spaces)

the sheet actually downloads the data but not two stocks. it's downloading only one stock data and pasting it in to two sheets.

any vba experts, pls check my code and tell me where i did mistake and how can i correct.
thank you.
 

manishchan

Well-Known Member
#2
dear,
i am trying to build( practicing VBA) a sheet which downloads two stocks data from yahoo.
pls find the sheet below as attached.

http://ww w. 4 shared . com/ file/ PWgLsj1lba/ try-2014.html

( remove spaces)

the sheet actually downloads the data but not two stocks. it's downloading only one stock data and pasting it in to two sheets.

any vba experts, pls check my code and tell me where i did mistake and how can i correct.
thank you.
What exactly are you trying to download.... just the stock price... or OHLC data ? The link you gave is not working.
 

vssoma

Well-Known Member
#3
What exactly are you trying to download.... just the stock price... or OHLC data ? The link you gave is not working.
dear,
i want to download daily stock1 prices(OHLC) in one sheet and stock2 daily prices(OHLC) in another sheet.
by the way, link is opening for me

http://www. 4shared. com/file/PWgLsj1lba/try-2014.html


 
Last edited:

manishchan

Well-Known Member
#4
dear,
i want to download daily stock1 prices(OHLC) in one sheet and stock2 daily prices(OHLC) in another sheet.
by the way, link is opening for me

http://www. 4shared. com/file/PWgLsj1lba/try-2014.html


If you want just the OHLC data.. you can download from google finance. Search fro google finance hisotorical data. you can just do web querry. No need for VBA
 

vssoma

Well-Known Member
#5
If you want just the OHLC data.. you can download from google finance. Search fro google finance hisotorical data. you can just do web querry. No need for VBA
dear, here in this place web query will not work. because, i'll change from n to date....in google finance it has multiple data and web quere will show u only 1 page...to download multiple pages this method is only the solution which i used.

this method i copied from net only...but that has only one stock at a time. but here i want two stocks at same time.

hope i explained clearly...
 

josh1

Well-Known Member
#6
Change your second query to this ....

Code:
qurl2 = qurl2 & "&a=" & Month(StartDate) - 1 & "&b=" & Day(StartDate) & _
       "&c=" & Year(StartDate) & "&d=" & Month(EndDate) - 1 & "&e=" & _
       Day(EndDate) & "&f=" & Year(EndDate) & "&g=" & Sheets("S2").Range("a2") & "&q=q&y=0&z=" & _
       Symbol2 & "&x=.csv"
 

vssoma

Well-Known Member
#7
Change your second query to this ....

Code:
qurl2 = qurl2 & "&a=" & Month(StartDate) - 1 & "&b=" & Day(StartDate) & _
       "&c=" & Year(StartDate) & "&d=" & Month(EndDate) - 1 & "&e=" & _
       Day(EndDate) & "&f=" & Year(EndDate) & "&g=" & Sheets("S2").Range("a2") & "&q=q&y=0&z=" & _
       Symbol2 & "&x=.csv"
dear,
thank you josh, it's working fine...
 

josh1

Well-Known Member
#8
dear,
thank you josh, it's working fine...
For multiple stocks, you can put single query in a for .. next loop and change the destination sheet accordingly.
 

Similar threads