Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Error handling part way though code

I have a code that refresh data. Sometime's no data is retrived and
code stops.
What is best way to handel this error. I have following but am sure
there must be a better way to do it as have a lot of error handeling
to add.


'Update Firmorders
On Error GoTo 1
Sheets("Firm orders on RF").Visible = True
Sheets("Firm orders on RF").Select
Range("A3").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Sheets("Firm orders on RF").Visible = False
1 Range("A3").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Sheets("Firm orders on RF").Visible = False
GoTo 2

2 UserForm1.Label4.Caption = "Step 3 in progress"
UserForm1.Repaint

'Update Firm orders not on RF
On Error GoTo 3
Sheets("Firm orders not on RF").Visible = True
Sheets("Firm orders not on RF").Select
Range("A3").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Sheets("Firm orders not on RF").Visible = False
3 Range("A3").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Sheets("Firm orders not on RF").Visible = False
GoTo 4

4 UserForm1.Label4.Caption = "Step 4 in progress"
UserForm1.Repaint

Thanks for any help
Simon
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Error handling part way though code

don't know about the the error, but this may simplify the clearing of the cells.

Set rng = Range("A3")
Range(Range(rng, rng.End(xlToRight)), Range(rng, rng.End(xlDown))).ClearContents

instead of:
Range("A3").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents


--


Gary


"Sliman" wrote in message
...
I have a code that refresh data. Sometime's no data is retrived and
code stops.
What is best way to handel this error. I have following but am sure
there must be a better way to do it as have a lot of error handeling
to add.


'Update Firmorders
On Error GoTo 1
Sheets("Firm orders on RF").Visible = True
Sheets("Firm orders on RF").Select
Range("A3").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Sheets("Firm orders on RF").Visible = False
1 Range("A3").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Sheets("Firm orders on RF").Visible = False
GoTo 2

2 UserForm1.Label4.Caption = "Step 3 in progress"
UserForm1.Repaint

'Update Firm orders not on RF
On Error GoTo 3
Sheets("Firm orders not on RF").Visible = True
Sheets("Firm orders not on RF").Select
Range("A3").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Sheets("Firm orders not on RF").Visible = False
3 Range("A3").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Sheets("Firm orders not on RF").Visible = False
GoTo 4

4 UserForm1.Label4.Caption = "Step 4 in progress"
UserForm1.Repaint

Thanks for any help
Simon



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
Code for Error handling using F5 from debug mode SG Excel Programming 0 January 30th 08 08:47 PM
Managed code error handling from VBA Prasanna Excel Programming 0 January 10th 08 04:02 PM
Incorporating error handling to Bob's code klysell Excel Programming 11 February 20th 07 11:05 PM
Error handling in this code L. Howard Kittle Excel Discussion (Misc queries) 4 October 8th 05 12:35 PM
VB handling on mdi print error code 1004 Walter L. skinner Excel Programming 1 October 5th 05 03:30 PM


All times are GMT +1. The time now is 10:10 PM.

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

About Us

"It's about Microsoft Excel"