![]() |
#28
|
||||
|
||||
![]()
Ah, I see. I was picturing logic that works roughly like this:
Code:
For <page counter> = 1 To <last page> Run the query for page <page counter>, writing over previous page Read through the downloaded data and rearrange it into a receiving worksheet Next <page counter> 'that is, go back and do the same for the next page Code:
For <page counter> = 1 To <last page> Run the query for <page counter>, copying below the previous page Next <page counter> Arrange the assembled data, ALL pages, into a receiving worksheet Quote:
If you want to grab all the pages, then move all their data around, that has to change. I thought it would be easy: Just use the same QueryTable, changing the Destination each time the loop iterates. It turns out, though (I played with it today) that the Destination property is read-only; it's set at QueryTable.Add time and cannot be changed. So if you're going to run all the pages before rearranging any of them, we'll have to preserve all the data by putting each page in a different Destination in the worksheet. You were trying to do that when you found the last row and set a new range for the Destination; you just did it wrong. You were thinking that if you set the second range to K1:K<lastrow>, Excel would automatically put the second page after that. But no; the second query goes in K1, because after all that's what it thought you were telling it to do. Here's what you do instead: set the Destination to K<lastrow+1>. In my program I did it this way: Code:
For Y = 1 To 5 'Mid(ActiveCell.Value, 2) - 1 URL = "URL;" & Range("A3").Value & "&page=" & Y Set vd = Range("K" & Rows.Count).End(xlUp).Offset(1, 0) With ActiveSheet.QueryTables.Add(Connection:=URL, Destination:=vd) .WebSelectionType = xlEntirePage .WebFormatting = xlWebFormattingNone .Refresh BackgroundQuery:=False End With Next Y Code:
For Y = 1 To Mid(ActiveCell.Value, 2) - 1 'blah, blah, blah Y = Y + 1 'drop this statement Next Y |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Match two sets of data and display specific data | lolly150 | Excel | 1 | 05-14-2012 10:33 PM |
Edit Data Source- Linking template charts to new data | lbf | PowerPoint | 0 | 10-28-2011 12:19 PM |
Powerpoint: adding data to trend lines w/o data labels | HaiLe | PowerPoint | 0 | 04-11-2011 09:21 AM |