View Single Post
  #1   Report Post  
 
Posts: n/a
Default Refreshing Data In Excel / VBA

Hello,

I wonder if anyone can help me please ?
(I've tried using the search, but couldn't find what I was looking for)

I have a spreadsheet which pulls data from a database using get
external data.
In this spreadsheet I have a macro which on the press of a button,
refreshes this data.
(It does this for multiple sheets, as there is a lot of data in there)

It then does other bits and pieces like Saving it as a new name etc.
This all works fine.

However, on occassions it must be experiencing problem with 'Timeout'
as I get the message "General ODBC error"

This obviously prevents the rest of my code from working.

I really want to put something like a loop in there which will say
something like :

If the query refreshes, then continue onto the next one.
However, if the query doesn't refresh for whatever reason, do it again
until it does, then move onto the next one.

I assume this is possible, but I really don't know the syntax as I'm
very new to this.

Here is the relevant part of my code :


VBA:
Sheets("Dashboard").Select
Range("B5").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("B19").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("G5").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("G19").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
If anyone can help me I'd be most grateful.

Thanks.

J.