Suppressing VBA Errors

  • Thread starter Thread starter Andrew
  • Start date Start date
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top