I have recorded a macro that will use a web query to obtain the latest price of the microsoft (msft) stock. I want to use this macro to get data on other stocks. My thought is to use an input box that asks me to type in the ticker name. The macro will then use this input to obtain the latest price of whatever ticker i type in. I can't figure out how to put the input box data into the macro. In the macro below, I want to put X wherever the web query uses the ticker msft. My plan is to add a bunch of web queries to the macro so when I type in the ticker name into the input box, the macro will return financial sheets, rations, etc:
Sub Getquote()
'
' Getquote Macro
' Macro recorded 1/8/2011 by CLAY D
'
' Keyboard Shortcut: Ctrl+q
'
X = InputBox("enter ticker", "ticker name")
With ActiveSheet.Que ryTables.Add(Co nnection:= _
"URL;http://finance.yahoo.c om/q?s=msft", Destination:=Ra nge("F27"))
.Name = "q?s=msft_1 "
.FieldNames = True
.RowNumbers = False
.FillAdjacentFo rmulas = False
.PreserveFormat ting = True
.RefreshOnFileO pen = False
.BackgroundQuer y = True
.RefreshStyle = xlInsertDeleteC ells
.SavePassword = False
.SaveData = True
.AdjustColumnWi dth = True
.RefreshPeriod = 0
.WebSelectionTy pe = xlSpecifiedTabl es
.WebFormatting = xlWebFormatting None
.WebTables = """table1"" "
.WebPreFormatte dTextToColumns = True
.WebConsecutive DelimitersAsOne = True
.WebSingleBlock TextImport = False
.WebDisableDate Recognition = False
.WebDisableRedi rections = False
.Refresh BackgroundQuery :=False
End With
End Sub
Sub Getquote()
'
' Getquote Macro
' Macro recorded 1/8/2011 by CLAY D
'
' Keyboard Shortcut: Ctrl+q
'
X = InputBox("enter ticker", "ticker name")
With ActiveSheet.Que ryTables.Add(Co nnection:= _
"URL;http://finance.yahoo.c om/q?s=msft", Destination:=Ra nge("F27"))
.Name = "q?s=msft_1 "
.FieldNames = True
.RowNumbers = False
.FillAdjacentFo rmulas = False
.PreserveFormat ting = True
.RefreshOnFileO pen = False
.BackgroundQuer y = True
.RefreshStyle = xlInsertDeleteC ells
.SavePassword = False
.SaveData = True
.AdjustColumnWi dth = True
.RefreshPeriod = 0
.WebSelectionTy pe = xlSpecifiedTabl es
.WebFormatting = xlWebFormatting None
.WebTables = """table1"" "
.WebPreFormatte dTextToColumns = True
.WebConsecutive DelimitersAsOne = True
.WebSingleBlock TextImport = False
.WebDisableDate Recognition = False
.WebDisableRedi rections = False
.Refresh BackgroundQuery :=False
End With
End Sub
Comment