Web Query address parameter

  • Thread starter Thread starter buckle
  • Start date Start date
B

buckle

I've created a Web Query that retrieves information about a certain stock.
Instead of modifying a parameter in the web query address when I want to
select a different stock, is there a way to insert the text from a cell on
the spreadsheet?

example: http://www.finance.yahoo.com/q?s=ibm gets me IBM. Can the parameter
"IBM" get input by the user or selected from a cell (say +a10)?

Thanks
 
Hi,

Put the following code worksheet's (where A10 is) WORKSHEET_CHANGE event
Assumed your Web Query in sheet1


Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Count = 1 And Target.Row = 1 And Target.Column = 10 Then
Sheet1.QueryTables(1).Connection =
"URL;http://finance.yahoo.com/q?s=" + Target.Value
Sheet1.QueryTables(1).Refresh
End If

End Sub

--
Regards

Haldun Alay

To e-mail me, please remove AT and DOT from my e-mail address.
 
Hi Haldun,

I'm getting a value error with your sample. Is the Target.value returning a
value or string?

Just starting to learn VBE stuff, so I'm a little green.

Thanks
 
Back
Top