Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Multiple Web Queries
Hi - I am trying to get addresses for all NHS Trusts (UK Healthcare
organisatins) using web queries. Thus I have built a loop which changes the url for each iteration. While is kind of works... the problem is: a) I get a load of other junk back I don't need b) Unless I specify a really high row value (using jj) each on each itteration, the output seems to be shifted along a number of columns Anyone have any views as to what I can do to make this work a little better. Examples of the urls a http://www.nhs.uk/root/localnhsservi...ite.asp?id=RTV http://www.nhs.uk/root/localnhsservi...ite.asp?id=RGT http://www.nhs.uk/root/localnhsservi...ite.asp?id=REM The last 2 chars change for each trust of which there are 264 I have the following code: Sub test1() Dim hVar, tName As String Dim ii, jj As Integer jj = 2 For ii = 2 To 5 /* testing - this will become about 300 */ hVar = Sheets("nhs_List").Range("C" & ii) /* takes url from a worksheet cell */ tName = Sheets("nhs_List").Range("A" & ii) /* Takes trust name from a worksheet cell */ Range("E" & jj).Value = tName /* puts name in cell e2, e82, e162... etc With ActiveSheet.QueryTables.Add(Connection:= _ /* web query which parses hvar and gets data from each web location*/ "URL;" & Trim(hVar), _ Destination:=Sheets("nhs_list").Range("E" & jj)) .Name = "5 Boroughs Partnership NHS Trust" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .WebSelectionType = xlEntirePage .WebFormatting = xlWebFormattingNone .WebPreFormattedTextToColumns = True .WebConsecutiveDelimitersAsOne = True .WebSingleBlockTextImport = False .WebDisableDateRecognition = False .WebDisableRedirections = False .Refresh BackgroundQuery:=False End With 'range("E2").Select /* test code... */ 'ActiveCell.SpecialCells(xlLastCell).Select 'Range("R300").Select jj = jj + 80 /* increment row where next query will be put by 80 */ Next End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
queries with multiple criteria | Excel Discussion (Misc queries) | |||
Multiple queries under same connection | Excel Discussion (Misc queries) | |||
Multiple worksheet queries | Excel Worksheet Functions | |||
Excel Queries Against Multiple Databases | Excel Programming | |||
Multiple queries using *.dqy files | Excel Programming |