Click to See Complete Forum and Search --> : VBA error


ajaykon
March 29th, 2001, 02:24 PM
Hi all,
I have the following VBA code in the macro for my Excel SpreadSheet, but the macro is giving an error " RunTime error '1004', Application-defined or object-defined error".
I am on Win2k, MS-Office2K.



Range("B3").Select
Selection.QueryTable.Refresh BackgroundQuery:=false


The error points to the second line i.e. "Selection..."
I would also add that I am a newbee to VB, my strengts lie elsewhere. This was needed to upload some data to the spreadsheet

TIA

Ajay K

Andyb
March 29th, 2001, 03:00 PM
Hi Ajay,

I am going to assume that the spreadsheet you are trying to run this macro on contains a table which is linked to an external data source, yes?

If it is then fine, if it isn't the macro won't work. The macro is attempting to refresh the cells in the spreadsheet with the data stored externally. Also you need to make sure that the cell address is part of the table. i.e. If you applied B3 and it is not part of the table Excel will return the message you are getting.

I tried this and it worked first time

Worksheets(1).Range("a1").QueryTable.Refresh

Best of luck
Andy

ajaykon
March 29th, 2001, 03:18 PM
Andy,
Thanks Man, that really helped. It worked, I was having trouble with the ODBC.

Thanks
Ajay