S
SFitz08
I want to run a macro in excel that asks for a ticker symbol (ex. wag) I
store that into a variable and then run a webquery to take that input and
pull up the appropriate website. This works fine when the variable is at the
end of the web address. However, the variable that the user enters is
actually in the middle of the web address. I cant seem to fix this. Please
see code below. I am very very new to VB. I recorded a macro to get the code
shown below. Thank you!
Sub Macro3()
Dim tickersymbol As String
tickersymbol = InputBox("What is the ticker symbol?")
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://moneycentral.msn.com/investor/invsub/results/statemnt.aspx?Symbol=[& tickersymbol]&lstStatement=10YearSummary&stmtView=Ann" _
, Destination:=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 = """INCS"""
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
store that into a variable and then run a webquery to take that input and
pull up the appropriate website. This works fine when the variable is at the
end of the web address. However, the variable that the user enters is
actually in the middle of the web address. I cant seem to fix this. Please
see code below. I am very very new to VB. I recorded a macro to get the code
shown below. Thank you!
Sub Macro3()
Dim tickersymbol As String
tickersymbol = InputBox("What is the ticker symbol?")
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://moneycentral.msn.com/investor/invsub/results/statemnt.aspx?Symbol=[& tickersymbol]&lstStatement=10YearSummary&stmtView=Ann" _
, Destination:=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 = """INCS"""
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub