I've recorded a macro to download stock data from MSN and it works great. However, I want to be able to use the same macro to download data for other stocks based on data entered in a given cell in Excel.
I would like to enter a stock symbol in cell B7 and have it download the same information as seen below (for MSFT in example) for the symbol the user enters into a certain cell on the spreadsheet.
I believe the line with the URL needs to be modified to make the query dynamic, but can't remember the exact changes.
I know this is a simple request for most of you. Please forgive me as I am just learning
I would like to enter a stock symbol in cell B7 and have it download the same information as seen below (for MSFT in example) for the symbol the user enters into a certain cell on the spreadsheet.
I believe the line with the URL needs to be modified to make the query dynamic, but can't remember the exact changes.
I know this is a simple request for most of you. Please forgive me as I am just learning
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://moneycentral.msn.com/investor/invsub/results/hilite.asp?Symbol=MSFT" _
, Destination:=Range("G7"))
.Name = "hilite.asp?Symbol=MSFT"
.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 = """pg"",3,5,6,7,8"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
"URL;http://moneycentral.msn.com/investor/invsub/results/hilite.asp?Symbol=MSFT" _
, Destination:=Range("G7"))
.Name = "hilite.asp?Symbol=MSFT"
.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 = """pg"",3,5,6,7,8"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub