Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help With Query
I am hoping someone here can provide some help with a my VB program. The program cycles through a number of Web Queries (to get Fantasy Baseball Stats) and then copies selected data from the Web Query to a data table in another worksheet in the workbook. Getting that to work is easy enough. However, the program encounters a problem and stops when the web query fails. The solution I have found for this problem is to refresh the web query and continue. Do accomplish that I am using the code below which: Checks the query results If the results are Not OK, the program will cycle through 5 attempts at refreshing the data to obtain valid results. If after 5 tries the query still will not load, the program goes to my error handling code. If, or (once) the results are Ok, the program continues My trials so far indicate that this code works. However, it seems a bit "funky" so I thought I would see if anyone here can offer a more robust solution. TIA PC Sub Macro() For i = 1 to x ""Code that cycles through Web Querys...."" **This is the part I am questioning** 'Check The Query Sheets("Sheet1").Activate Ctr = 0 Do Until Ctr = 5 If Evaluate("ISERROR(SUMPRODUCT((_1=""Opp"")*(COLUMN( _1)))/SUMPRODUCT(--(_1=""O pp"")))") = "True" Then Ctr = Ctr + 1 Selection.QueryTable.Refresh BackgroundQuery:=False Else Ctr = 5 End If Loop If Evaluate("ISERROR(SUMPRODUCT((_1=""Opp"")*(COLUMN( _1)))/SUMPRODUCT(--(_1=""O pp"")))") = "True" Then GoTo Error End If Continue with rest of program where a lot of stuff is done....... Next i Exit Sub Error: End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Import New Database Query (Union Query) in Spreadsheet | Excel Discussion (Misc queries) | |||
Convert hard coded query criteria to Parameter Query | Excel Discussion (Misc queries) | |||
Excel 2007 / MS Query - editing existing query to another sheet | Excel Discussion (Misc queries) | |||
Anyone Else Use Database Query to Query Another Sheet in the Same Excel Workbook? | Excel Discussion (Misc queries) | |||
Microsoft Query rejects "nz" function in Access Query | Excel Discussion (Misc queries) |