I have an Excel sheet with about 20 queries which point to the same file. I need to change the location of the file that the query looks at. Is there an easy way to change it?
The easist solution, albeit not the necessarily the best depending on how your environment is set up, is to just to rename the old file (say xyz.xls) to xyz.old. Then rename the new file to xyz.xls and put it in the same place that the old one was. Excel will never know it is looking at a differant file as long as they are both formatted the same way.
From the dialog that opens up, you can change the linked file to suit your new requirements.
If you are using a Database query, you can press Alt and F11 to edit the macro in the Visual Basic Editor. Find the query and it will include the path and filename. Simply edit here and save the file. The query willl reference the new location. Assuming no changes required for formatting, things will work perfectly.
Generally, you need to use VBA and get the CONNECTION property which identifies the file used for the query. You can then change the connection property to point to a new file. Pivottables are a bit different as they have the pivottable and pivotCACHE elements which both need changing
Rgds, Geoff
"Three things are certain: Death, taxes and lost data. Guess which has occurred"
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.