Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Import New Database Query (Union Query) in Spreadsheet klock Excel Discussion (Misc queries) 2 September 24th 09 01:30 AM
Convert hard coded query criteria to Parameter Query Melanie[_2_] Excel Discussion (Misc queries) 0 July 15th 08 09:59 PM
Excel 2007 / MS Query - editing existing query to another sheet Hotpepperz Excel Discussion (Misc queries) 0 June 13th 08 06:53 PM
Anyone Else Use Database Query to Query Another Sheet in the Same Excel Workbook? jocke Excel Discussion (Misc queries) 0 November 28th 05 06:37 PM
Microsoft Query rejects "nz" function in Access Query Vaughan Excel Discussion (Misc queries) 0 May 4th 05 05:20 PM


All times are GMT +1. The time now is 11:09 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"