Suppressing VBA Errors

A

Andrew

I think I've seen a way to prevent (supress?) errors in VBA but hav
forgotten just how I should do it.

This is my code. As you can see, it's to update data in a Currenc
Conversion file that I made.

Sub CurrencyUpdate()
Range("C5").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
End Sub

Sometimes I get a Run-time error '1004' message saying "This web quer
returned no data".

Any solutions? Would appreciate any help
 
T

tinyjack

You should have a look at the On Error statement. You could use O
Error Resume Next in your example but it might be nicer to do somethin
like this:


Code
-------------------

Sub CurrencyUpdate()

On Error Goto ErrorHandler

Range("C5").QueryTable.Refresh BackgroundQuery:=False

Exit Sub

ErrorHandler:

MsgBox "No results returned"

End Sub

-------------------


HTH

T
 
Top