I am trying to write a script that will use Stock Symbol, Period Start and Period End dates entries to dynamically pull the info from the web. I recorded the setup of an External Data extract to kludge together a data string that adds the range of data I'm looking for (1 year previous to the start date to the end date) based on the users input. The problem is that it only captures the first page of the selected data. Anybody know what data property or variable I can add to the string to have it pull all the data? Better still, can anyone recommend a training guide to dynamic web extraction for Excel. Thanks
Range("ClearData").Select
StartDate = Range("StartDate").Value - 365
EndDate = Range("EndDate").Value
Stock = Range("Stock").Value
Incoming = "URL;http://finance.yahoo.com/q/hp?a=" _
& Format(Format(StartDate, "MM") - 1, "00") & "&b=" _
& Format(StartDate, "DD") & "&c=" _
& Format(StartDate, "YYYY") _
& "&d=" _
& Format(Format(EndDate, "MM") - 1, "00") & "&e=" _
& Format(EndDate, "DD") & "&f=" _
& Format(EndDate, "YYYY") & "&g=d&s=" _
& Stock
StockData = Range("StockData").Address
With ActiveSheet.QueryTables.Add(Connection:=Incoming _
, Destination:=Range(StockData))
.Name = "Stock Search"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "15"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Range("ClearData").Select
StartDate = Range("StartDate").Value - 365
EndDate = Range("EndDate").Value
Stock = Range("Stock").Value
Incoming = "URL;http://finance.yahoo.com/q/hp?a=" _
& Format(Format(StartDate, "MM") - 1, "00") & "&b=" _
& Format(StartDate, "DD") & "&c=" _
& Format(StartDate, "YYYY") _
& "&d=" _
& Format(Format(EndDate, "MM") - 1, "00") & "&e=" _
& Format(EndDate, "DD") & "&f=" _
& Format(EndDate, "YYYY") & "&g=d&s=" _
& Stock
StockData = Range("StockData").Address
With ActiveSheet.QueryTables.Add(Connection:=Incoming _
, Destination:=Range(StockData))
.Name = "Stock Search"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "15"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With