UPDATE – there’s now a better way to do this using copy/paste. See
Here’s a tip that I found out about on the Power Query Technet forum that I thought was worth repeating. If you ever need a quick way of exporting all the M code for all of the queries in an Excel 2013 workbook, just open the Power Query window and click the Send a Frown button shown here:
Then, when the Send Feedback dialog appears, make sure Include Formulas is ticked then click OK:
When you do that, you’ll get an email created for you that contains a whole lot of debugging information, plus all of the M code for your queries:
Obviously, don’t send this email to Microsoft!
It’s quite easy to see the individual queries. You then need to go to your new workbook, create a new query by selecting the Blank Query option under Other Sources, and then open the Advanced Editor window and paste the code for each query in. However, when you do that you will need to modify the code a bit. There are three pieces of code you will need to delete:
- At the beginning of the M code, where it says
- At the beginning of each query, a piece of code that contains the original name of the query:
shared MyOriginalQueryName =
- At the very end, a semi-colon
Of course in Excel 2016 we’ll have much better options for copying, pasting and moving queries in VBA, but until then we’ll have to live with hacks like this.