What is the correct syntax to refresh an external data query? I have tried
Sheets(“InputData”).QueryTable(“ReportData”).Refresh
Which gives me an error message .
Thanks for any help
Peter
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Syntax for QueryTable (XL2K)
Thanks for the info
I still have not found a way to refer to the query by name and am not sure how to find the number short of trial and error!
but have found this method which does what I need.
Worksheets(“InputData”).Range(“c10”).QueryTable.Refresh
would prefer to refer to query by name though in case I need to modify things!
Peter
You can index the QueryTables collection by name. As Rory pointed out, there is the QueryTables collection as opposed to the QueryTable property of a Range. You can determine the name by
Sheets("InputData").Range("C10").QueryTable.Name
If you used Excel to create the query, then Excel uses the Name “Query from XXXX”, where XXXX is the DataSource, so maybe Sheets(“InputData”).QueryTables(“Query from ReportData”).Refresh is what you need. You can also deternine the Query name from the Name box (to the left of the Formula bar). If you have the query with the name “Query from XXXX”, then you will have the name Query_from_XXXX in the drop-down. If you used VBA to create the query, then you should use the Name property to give it a useful name. HTH –Sam
Many Thanks for all of the replies
Rory had it exactly right! Surprising how much difference a little old “s” can make! Always used to be the punctuation that had me pulling my hair out
I was able to get the query name from the properties sheet for it on the External Data Tool Bar
Cheers all
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.
Notifications