View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sliman Sliman is offline
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