Stock quotes from web site

M

Melwin

Hi,

I want to make a public function that takes a stock ticker as input and
searches a specified website for the latest price information. How shall I do
this?

Thank you for your help
 
R

ryguy7272

Put the stock symbol in cell A1, then run this macro:
Sub Macro2()


Rows("2:65536").Select
Selection.ClearContents
Range("A1").Select

With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://finance.yahoo.com/q?s=" & Range("A1"),
Destination:=Range("A2"))
.Name = "q?s=" & Range("A1")
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = """table1"",""table2"""
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With

End Sub

See this site for information on running a macro:
http://www.anthony-vba.kefra.com/vba/vbabasic1.htm#Creating_Your_First_Macro

Finally, if you right click on that sheet tab, and paste this code into the
window that opens:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
ThisWorkbook.FollowHyperlink _
Address:="http://finance.yahoo.com/q/pr?s=" & _
Target.Text
Cancel = True
End Sub

You can double-click on the cell with the security symbol in it (remember it
is in A1) and a window will open with lots and lots of good information
pertaining to that particular security.

All you have to do now is decide how you will spend all the ridiculous
amounts of money that you are going to make...

Regards,
Ryan---
 

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