Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a simple piece of code below that refresh's some web queries to
get stock prices. What I have encountered is that sometimes a particular query will return an error (web page not available etc), what I wish to do, is if that happens, just bypass the particular query and move to the next one. How would I incorporate that in to be code? Sub GetLatestPrices() Application.ScreenUpdating = False Sheets("Web Prices").Activate ActiveSheet.Visible = True Range("A3").Select Selection.QueryTable.Refresh BackgroundQuery:=False Range("A14").Select Selection.QueryTable.Refresh BackgroundQuery:=False Range("A25").Select Selection.QueryTable.Refresh BackgroundQuery:=False Application.ScreenUpdating = True End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You can ignore errors by using an On Error Resume Next statement. Note
that this does not by any measure *fix* an error; it merely ignores the error and allows the code to continue running. The error may have side effects. Generally, a blanket On Error Resume Next is dangerous because it ignores all errors, not just a particular type of error, but in the context of a small procedure like the one you illustrate, it is probably fine to use on On Error Resume Next statement for the entire procedure. E.g, Sub GetLatestPrices() On Error Resume Next ' your existing code goes here End Sub I have quite a bit of information about error handling at http://www.cpearson.com/Excel/ErrorHandling.htm . Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group Pearson Software Consulting, LLC www.cpearson.com (email on web site) On Thu, 16 Oct 2008 09:18:46 -0700 (PDT), Sean wrote: I have a simple piece of code below that refresh's some web queries to get stock prices. What I have encountered is that sometimes a particular query will return an error (web page not available etc), what I wish to do, is if that happens, just bypass the particular query and move to the next one. How would I incorporate that in to be code? Sub GetLatestPrices() Application.ScreenUpdating = False Sheets("Web Prices").Activate ActiveSheet.Visible = True Range("A3").Select Selection.QueryTable.Refresh BackgroundQuery:=False Range("A14").Select Selection.QueryTable.Refresh BackgroundQuery:=False Range("A25").Select Selection.QueryTable.Refresh BackgroundQuery:=False Application.ScreenUpdating = True End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Chip
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Bypass Auto_Open | Excel Programming | |||
How to bypass Excel error message | Excel Programming | |||
Bypass Worksheet_Change Sub | Excel Programming | |||
Bypass an | Excel Programming | |||
How to "bypass" run-time error '91'???? | Excel Programming |