Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Yahoo Quotes Macro stops functioning

I have been running a macro for eight months now that pulls current quotes
from Yahoo and puts them in a spreadsheet. For reasons unknown, the first
quote, S&P500 index, has stopped functioning. The macro returns the name of
the index as "%5EGSPC" whereas it should be "S&P500". The ticker, ^GSPC,
works on their website. I do not believe I've made macro changes that would
affect this in any way.

Please advise if you've encountered this problem and, better yet, a
solution. Thanks, John

code starts he

Sub GetData2()

Dim rCell As Range, rSymb As Range
Dim sYahooUrl As String
Dim qt As QueryTable
Dim rQtStart As Range

Set rQtStart = Sheet1.Range("A40")
Set rSymb = Sheet1.Range("B2", Sheet1.Range("B29").End(xlUp))
sYahooUrl = "URL;http://quote.yahoo.com/d/quotes.csv?s=^GSPC"

'build url with column B
For Each rCell In rSymb.Cells
sYahooUrl = sYahooUrl & "+" & rCell.Value
Next rCell

sYahooUrl = sYahooUrl & "&f=nl1c"

'get a query table if it exits
On Error Resume Next
Set qt = rQtStart.QueryTable
On Error GoTo 0

If qt Is Nothing Then 'create new
Set qt = Sheet1.QueryTables.Add(sYahooUrl, rQtStart)
Else 'update existing
qt.Connection = sYahooUrl
End If
On Error Resume Next
qt.Refresh False

'parse results
Application.DisplayAlerts = False
qt.ResultRange.TextToColumns _
Destination:=qt.ResultRange.Cells(1), _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, _
Comma:=True
Application.DisplayAlerts = True

'reschedule update
StartTimer
Debug.Print Sheet1.QueryTables.Count

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Yahoo Quotes Macro stops functioning

try
"http://download.finance.yahoo.com/d/quotes.csv?s=^GSPC"

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"John V" wrote in message
...
I have been running a macro for eight months now that pulls current quotes
from Yahoo and puts them in a spreadsheet. For reasons unknown, the first
quote, S&P500 index, has stopped functioning. The macro returns the name
of
the index as "%5EGSPC" whereas it should be "S&P500". The ticker, ^GSPC,
works on their website. I do not believe I've made macro changes that
would
affect this in any way.

Please advise if you've encountered this problem and, better yet, a
solution. Thanks, John

code starts he

Sub GetData2()

Dim rCell As Range, rSymb As Range
Dim sYahooUrl As String
Dim qt As QueryTable
Dim rQtStart As Range

Set rQtStart = Sheet1.Range("A40")
Set rSymb = Sheet1.Range("B2", Sheet1.Range("B29").End(xlUp))
sYahooUrl = "URL;http://quote.yahoo.com/d/quotes.csv?s=^GSPC"

'build url with column B
For Each rCell In rSymb.Cells
sYahooUrl = sYahooUrl & "+" & rCell.Value
Next rCell

sYahooUrl = sYahooUrl & "&f=nl1c"

'get a query table if it exits
On Error Resume Next
Set qt = rQtStart.QueryTable
On Error GoTo 0

If qt Is Nothing Then 'create new
Set qt = Sheet1.QueryTables.Add(sYahooUrl, rQtStart)
Else 'update existing
qt.Connection = sYahooUrl
End If
On Error Resume Next
qt.Refresh False

'parse results
Application.DisplayAlerts = False
qt.ResultRange.TextToColumns _
Destination:=qt.ResultRange.Cells(1), _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, _
Comma:=True
Application.DisplayAlerts = True

'reschedule update
StartTimer
Debug.Print Sheet1.QueryTables.Count

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Yahoo Quotes Macro stops functioning

No soap. This change returns an empty array. With quote.yahoo.com, I do
continue to get other stock quotes that follow without problem. It's just S&P.

I'll post if I solve the mystery.

"Don Guillett" wrote:

try
"http://download.finance.yahoo.com/d/quotes.csv?s=^GSPC"

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"John V" wrote in message
...
I have been running a macro for eight months now that pulls current quotes
from Yahoo and puts them in a spreadsheet. For reasons unknown, the first
quote, S&P500 index, has stopped functioning. The macro returns the name
of
the index as "%5EGSPC" whereas it should be "S&P500". The ticker, ^GSPC,
works on their website. I do not believe I've made macro changes that
would
affect this in any way.

Please advise if you've encountered this problem and, better yet, a
solution. Thanks, John

code starts he

Sub GetData2()

Dim rCell As Range, rSymb As Range
Dim sYahooUrl As String
Dim qt As QueryTable
Dim rQtStart As Range

Set rQtStart = Sheet1.Range("A40")
Set rSymb = Sheet1.Range("B2", Sheet1.Range("B29").End(xlUp))
sYahooUrl = "URL;http://quote.yahoo.com/d/quotes.csv?s=^GSPC"

'build url with column B
For Each rCell In rSymb.Cells
sYahooUrl = sYahooUrl & "+" & rCell.Value
Next rCell

sYahooUrl = sYahooUrl & "&f=nl1c"

'get a query table if it exits
On Error Resume Next
Set qt = rQtStart.QueryTable
On Error GoTo 0

If qt Is Nothing Then 'create new
Set qt = Sheet1.QueryTables.Add(sYahooUrl, rQtStart)
Else 'update existing
qt.Connection = sYahooUrl
End If
On Error Resume Next
qt.Refresh False

'parse results
Application.DisplayAlerts = False
qt.ResultRange.TextToColumns _
Destination:=qt.ResultRange.Cells(1), _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, _
Comma:=True
Application.DisplayAlerts = True

'reschedule update
StartTimer
Debug.Print Sheet1.QueryTables.Count

End Sub




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Yahoo Quotes Macro stops functioning

The problem seems to be the carat symbol. Any index prefixed with a "^" is
not interpreted properly. It translates the carat into "%5E" when returning
the name of the index.

Any alternative methods of designating a "^" in VBA?

"John V" wrote:

No soap. This change returns an empty array. With quote.yahoo.com, I do
continue to get other stock quotes that follow without problem. It's just S&P.

I'll post if I solve the mystery.

"Don Guillett" wrote:

try
"http://download.finance.yahoo.com/d/quotes.csv?s=^GSPC"

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"John V" wrote in message
...
I have been running a macro for eight months now that pulls current quotes
from Yahoo and puts them in a spreadsheet. For reasons unknown, the first
quote, S&P500 index, has stopped functioning. The macro returns the name
of
the index as "%5EGSPC" whereas it should be "S&P500". The ticker, ^GSPC,
works on their website. I do not believe I've made macro changes that
would
affect this in any way.

Please advise if you've encountered this problem and, better yet, a
solution. Thanks, John

code starts he

Sub GetData2()

Dim rCell As Range, rSymb As Range
Dim sYahooUrl As String
Dim qt As QueryTable
Dim rQtStart As Range

Set rQtStart = Sheet1.Range("A40")
Set rSymb = Sheet1.Range("B2", Sheet1.Range("B29").End(xlUp))
sYahooUrl = "URL;http://quote.yahoo.com/d/quotes.csv?s=^GSPC"

'build url with column B
For Each rCell In rSymb.Cells
sYahooUrl = sYahooUrl & "+" & rCell.Value
Next rCell

sYahooUrl = sYahooUrl & "&f=nl1c"

'get a query table if it exits
On Error Resume Next
Set qt = rQtStart.QueryTable
On Error GoTo 0

If qt Is Nothing Then 'create new
Set qt = Sheet1.QueryTables.Add(sYahooUrl, rQtStart)
Else 'update existing
qt.Connection = sYahooUrl
End If
On Error Resume Next
qt.Refresh False

'parse results
Application.DisplayAlerts = False
qt.ResultRange.TextToColumns _
Destination:=qt.ResultRange.Cells(1), _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, _
Comma:=True
Application.DisplayAlerts = True

'reschedule update
StartTimer
Debug.Print Sheet1.QueryTables.Count

End Sub




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 897
Default Yahoo Quotes Macro stops functioning

CHAR(94) returns a "^" can you bake that into your string?

As an alternative, have you tried this add-in?

http://finance.groups.yahoo.com/group/smf_addin/

--JP

On Oct 20, 2:00*pm, John V wrote:
The problem seems to be the carat symbol. Any index prefixed with a "^" is
not interpreted properly. It translates the carat into "%5E" when returning
the name of the index.

Any alternative methods of designating a "^" in VBA?





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Yahoo Quotes Macro stops functioning

'sYahooUrl = "URL;http://quote.yahoo.com/d/quotes.csv?s=^GSPC"
sYahooUrl = "URL;http://download.finance.yahoo.com/d/quotes.csv?s=^GSPC"

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Don Guillett" wrote in message
...
try
"http://download.finance.yahoo.com/d/quotes.csv?s=^GSPC"

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"John V" wrote in message
...
I have been running a macro for eight months now that pulls current quotes
from Yahoo and puts them in a spreadsheet. For reasons unknown, the first
quote, S&P500 index, has stopped functioning. The macro returns the name
of
the index as "%5EGSPC" whereas it should be "S&P500". The ticker, ^GSPC,
works on their website. I do not believe I've made macro changes that
would
affect this in any way.

Please advise if you've encountered this problem and, better yet, a
solution. Thanks, John

code starts he

Sub GetData2()

Dim rCell As Range, rSymb As Range
Dim sYahooUrl As String
Dim qt As QueryTable
Dim rQtStart As Range

Set rQtStart = Sheet1.Range("A40")
Set rSymb = Sheet1.Range("B2", Sheet1.Range("B29").End(xlUp))
sYahooUrl = "URL;http://quote.yahoo.com/d/quotes.csv?s=^GSPC"

'build url with column B
For Each rCell In rSymb.Cells
sYahooUrl = sYahooUrl & "+" & rCell.Value
Next rCell

sYahooUrl = sYahooUrl & "&f=nl1c"

'get a query table if it exits
On Error Resume Next
Set qt = rQtStart.QueryTable
On Error GoTo 0

If qt Is Nothing Then 'create new
Set qt = Sheet1.QueryTables.Add(sYahooUrl, rQtStart)
Else 'update existing
qt.Connection = sYahooUrl
End If
On Error Resume Next
qt.Refresh False

'parse results
Application.DisplayAlerts = False
qt.ResultRange.TextToColumns _
Destination:=qt.ResultRange.Cells(1), _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, _
Comma:=True
Application.DisplayAlerts = True

'reschedule update
StartTimer
Debug.Print Sheet1.QueryTables.Count

End Sub




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
Data Validation in XL2007 suddenly stops functioning ker_01 Excel Discussion (Misc queries) 0 January 29th 10 11:58 PM
Hyperlink to Bookmark stops functioning Frances D Links and Linking in Excel 0 November 21st 06 04:47 PM
Pulling stock quotes from Yahoo Finance into a spreadsheet [email protected] Excel Discussion (Misc queries) 1 November 8th 06 10:09 AM
Historical Stock Quotes - Yahoo Finance Jason Excel Programming 4 July 4th 05 12:40 AM
Yahoo quotes error in Excel Peter Benson Excel Programming 9 February 18th 04 07:35 AM


All times are GMT +1. The time now is 02:08 AM.

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

About Us

"It's about Microsoft Excel"