Web Query address parameter

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
 
H

Haldun Alay

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.
 
B

buckle

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top