?
Solved

Excel VBA query

Posted on 2013-01-25
3
Medium Priority
?
217 Views
Last Modified: 2013-01-25
I have a SQL query in cell D12, Sheet1 in Excel 2007.

I'd like to refresh that query via a button... I don't want the query in B4 to execute.

These don't work:

mySheet.Range("D12").QueryTable.Refresh
mySheet.Range("D12").QueryTable().Refresh
mySheet.Range("D12").QueryTable(0).Refresh

Any ideas?
0
Comment
Question by:classnet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
Shanan212 earned 2000 total points
ID: 38819783
mySheet.QueryTables(1).CommandText = mysheet.range("D12")
mySheet.QueryTables(1).refresh BackgroundQuery:=True

Open in new window


Let me know!
0
 

Author Comment

by:classnet
ID: 38819827
This yields a:

Application-defined or object-defined error

on this row

wksCaC.QueryTables(0).CommandText = wksCaC.Range("D12")
0
 

Author Closing Comment

by:classnet
ID: 38820432
Typo... thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question