View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Fid[_2_] Fid[_2_] is offline
external usenet poster
 
Posts: 16
Default Querytables refresh gives Subscript out of Range Error

In Excel 2007 I have the very simple code (abridged for clarity):

Private Sub cmdRefreshRMTable_Click()
With Workbooks("RM_Master.xls").Worksheets("ESC_RM_Cost ")
.QueryTables(1).Refresh BackgroundQuery:=False
End With
End Sub

that gives me a subscript out of range error on the refresh method.
The workbook name is spelled correctly, the worksheet name is spelled
correctly and there is only one query table in the entire workbook.

In Excel 2003 this same code works properly.

What am I missing?