View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
PJFry PJFry is offline
external usenet poster
 
Posts: 143
Default Refreshing External Data Ranges

It is designed to run nine times. I just hit the record button and refreshed
everything manually. If I change the order of the sheets or move the
location of the external data the whole thing would break.

If I can reference the names directly, then I won't have to worry about
order.


Sheets("SupplierInput").Select
Range("C1").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("A19").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
ActiveSheet.Next.Select
ActiveSheet.Next.Select
ActiveSheet.Next.Select
ActiveSheet.Next.Select
Range("A2").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("A6").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
ActiveSheet.Next.Select
ActiveSheet.Next.Select
Range("A1").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("A5").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
ActiveSheet.Next.Select
ActiveSheet.Next.Select
Range("A1").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("A5").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
ActiveSheet.Next.Select
ActiveSheet.Next.Select
Range("A1").Select
Selection.QueryTable.Refresh BackgroundQuery:=False

"PJFry" wrote:

I have a macro that I recorded to update an external range named
Ralston_SupplierInput. The data come an Access db.

Here is a piece of the code:

'Move the the sheet containing the external data range
Sheets("SupplierInput").Select
'Select a cell in the data range
Range("C1").Select
'Refresh the range
Selection.QueryTable.Refresh BackgroundQuery:=False

It runs the same code nine times, selecting in a new sheet and range each
time. Is there a way to refresh this data range by simply referencing the
name of the range?

My preference is to have more control over the process than having an
automatic refresh or needing to open and close the document to refresh.

Thanks!
PJ