Excel Query - Code problem

  • Thread starter Thread starter Reney Langlois
  • Start date Start date
R

Reney Langlois

I have a query on a spreadsheet that grabs data from a
database on a corporate server. I can manipulate the
results of the query directly on the sheet, but I can't
use code to reference any of the cells. If I try to
select a cell in code, I get an error '1004' - Select
method of range class failed. Any ideas?
 
I guess there might be more ideas if you posted the code that's giving you a
problem

Regards

Trevor
 
As I was paging through some of the other postings,
someone gave the advice of using ActiveSheet.Range rather
than just Range.... I tried this and it worked. The new
code is below. I click a button from another sheet, the
embedded query is on the worksheet "Project". The
original code would crash when I tried to select cell A1
with the simple Range("a1").select command. The code
below works. I'm going to go with this for now.

Private Sub cmdUpdate_Click()

Worksheets("project").Select
ActiveSheet.Range("a1").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
 

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

Back
Top