Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Change VBA Code,Stock look up

I have this code that downloads stock quotes into Excel
from Yahoo.It was posted some time ago on the newsgroup
boards by a poster named, HTH Shockley.

Sub GetYQuotes()
Base01 = "http://finance.yahoo.com/d/quotes.csv?s="
Base02 = "&f=sl1d1t1c1ohgv&e=.csv"

sURL = ""
SymString = ""
LastRow = Cells(65536, 1).End(xlUp).Row
For i = 1 To LastRow
SymString = SymString & Cells(i, 1) & " "
Next i
sURL = Base01 & SymString & Base02
Workbooks.Open sURL
Set rngSource = Cells(1).CurrentRegion
x = rngSource.Rows.Count
y = rngSource.Columns.Count
With ThisWorkbook.Sheets(1)
Set rngDest = Range(.Cells(1, 1), .Cells(x, y))
End With
rngDest.Value = rngSource.Value
ActiveWorkbook.Close SaveChanges:=False
End Sub

This code uses a list of symbols in the first column of
the first sheet in the workbook and gets basic quotes from
Yahoo.Instead of the first column I would like to be able
to assign a column(range?)for the symbols that are to be
looked up. For example; column("B") or range(B1:B20).
Would I need to change the destination range too? I new to
this gave it a shot and failed. Please help

thanks in advance,
Paul
P.S.using Office 2000
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Change VBA Code,Stock look up

Change


LastRow = Cells(65536, 1).End(xlUp).Row
For i = 1 To LastRow
SymString = SymString & Cells(i, 1) & " "
Next i


to

Dim cell as Range
for each cell in worksheets("Sheet1").Range("B1:B20")
SymString = SymString & Cell & " "
Next

The destination is a new workbook, so you don't need to change that.

--
Regards,
Tom Ogilvy


paul wrote in message
...
I have this code that downloads stock quotes into Excel
from Yahoo.It was posted some time ago on the newsgroup
boards by a poster named, HTH Shockley.

Sub GetYQuotes()
Base01 = "http://finance.yahoo.com/d/quotes.csv?s="
Base02 = "&f=sl1d1t1c1ohgv&e=.csv"

sURL = ""
SymString = ""
LastRow = Cells(65536, 1).End(xlUp).Row
For i = 1 To LastRow
SymString = SymString & Cells(i, 1) & " "
Next i
sURL = Base01 & SymString & Base02
Workbooks.Open sURL
Set rngSource = Cells(1).CurrentRegion
x = rngSource.Rows.Count
y = rngSource.Columns.Count
With ThisWorkbook.Sheets(1)
Set rngDest = Range(.Cells(1, 1), .Cells(x, y))
End With
rngDest.Value = rngSource.Value
ActiveWorkbook.Close SaveChanges:=False
End Sub

This code uses a list of symbols in the first column of
the first sheet in the workbook and gets basic quotes from
Yahoo.Instead of the first column I would like to be able
to assign a column(range?)for the symbols that are to be
looked up. For example; column("B") or range(B1:B20).
Would I need to change the destination range too? I new to
this gave it a shot and failed. Please help

thanks in advance,
Paul
P.S.using Office 2000



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Change VBA Code,Stock look up


-----Original Message-----
Change


LastRow = Cells(65536, 1).End(xlUp).Row
For i = 1 To LastRow
SymString = SymString & Cells(i, 1) & " "
Next i


to

Dim cell as Range
for each cell in worksheets("Sheet1").Range("B1:B20")
SymString = SymString & Cell & " "
Next

The destination is a new workbook, so you don't need to

change that.

--
Regards,
Tom Ogilvy


paul wrote in

message
...
I have this code that downloads stock quotes into Excel
from Yahoo.It was posted some time ago on the newsgroup
boards by a poster named, HTH Shockley.

Sub GetYQuotes()
Base01 = "http://finance.yahoo.com/d/quotes.csv?s="
Base02 = "&f=sl1d1t1c1ohgv&e=.csv"

sURL = ""
SymString = ""
LastRow = Cells(65536, 1).End(xlUp).Row
For i = 1 To LastRow
SymString = SymString & Cells(i, 1) & " "
Next i
sURL = Base01 & SymString & Base02
Workbooks.Open sURL
Set rngSource = Cells(1).CurrentRegion
x = rngSource.Rows.Count
y = rngSource.Columns.Count
With ThisWorkbook.Sheets(1)
Set rngDest = Range(.Cells(1, 1), .Cells(x, y))
End With
rngDest.Value = rngSource.Value
ActiveWorkbook.Close SaveChanges:=False
End Sub

This code uses a list of symbols in the first column of
the first sheet in the workbook and gets basic quotes

from
Yahoo.Instead of the first column I would like to be

able
to assign a column(range?)for the symbols that are to be
looked up. For example; column("B") or range(B1:B20).
Would I need to change the destination range too? I new

to
this gave it a shot and failed. Please help

thanks in advance,
Paul
P.S.using Office 2000



Thanks so very much Tom.

Happy holidays to you an your family.

Paul

  #4   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default one more question.

The change worked great.
When I put a second range of symbols below the first the
data go up to the first open cell. In my case that would
be B1.How do I make keep the data aligned next to my
second set of symbols(Mysymbols=A30:A47)I know that I will
have to make a second macro then run them sequentially.But
how do I go about keeping them aligned? It looks like this
part to me.
Workbooks.Open sURL
Set rngSource = Cells(1).CurrentRegion
x = rngSource.Rows.Count
y = rngSource.Columns.Count
With ThisWorkbook.Sheets(2)
Set rngDest = Range(.Cells(1, 1), .Cells(x, y))
But again I am lost.

Thanks again,
Paul
-----Original Message-----
Change


LastRow = Cells(65536, 1).End(xlUp).Row
For i = 1 To LastRow
SymString = SymString & Cells(i, 1) & " "
Next i


to

Dim cell as Range
for each cell in worksheets("Sheet1").Range("B1:B20")
SymString = SymString & Cell & " "
Next

The destination is a new workbook, so you don't need to

change that.

--
Regards,
Tom Ogilvy


paul wrote in

message
...
I have this code that downloads stock quotes into Excel
from Yahoo.It was posted some time ago on the newsgroup
boards by a poster named, HTH Shockley.

Sub GetYQuotes()
Base01 = "http://finance.yahoo.com/d/quotes.csv?s="
Base02 = "&f=sl1d1t1c1ohgv&e=.csv"

sURL = ""
SymString = ""
LastRow = Cells(65536, 1).End(xlUp).Row
For i = 1 To LastRow
SymString = SymString & Cells(i, 1) & " "
Next i
sURL = Base01 & SymString & Base02
Workbooks.Open sURL
Set rngSource = Cells(1).CurrentRegion
x = rngSource.Rows.Count
y = rngSource.Columns.Count
With ThisWorkbook.Sheets(1)
Set rngDest = Range(.Cells(1, 1), .Cells(x, y))
End With
rngDest.Value = rngSource.Value
ActiveWorkbook.Close SaveChanges:=False
End Sub

This code uses a list of symbols in the first column of
the first sheet in the workbook and gets basic quotes

from
Yahoo.Instead of the first column I would like to be

able
to assign a column(range?)for the symbols that are to be
looked up. For example; column("B") or range(B1:B20).
Would I need to change the destination range too? I new

to
this gave it a shot and failed. Please help

thanks in advance,
Paul
P.S.using Office 2000



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Select stock code depending on description in next column sako 338 Excel Worksheet Functions 4 March 1st 07 02:32 AM
How to return the Number of shares for a given stock code for a given portfolio aray Excel Discussion (Misc queries) 1 May 18th 06 04:50 AM
stock change Knowledge001 Excel Discussion (Misc queries) 3 October 19th 05 03:01 AM
Stock change Knowledge001 Excel Discussion (Misc queries) 2 October 19th 05 12:06 AM
How do I set up excel so you enter a stock code and it brings up . kieronm Excel Discussion (Misc queries) 1 January 12th 05 11:01 AM


All times are GMT +1. The time now is 10:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"