Increment Variable in Power Query

alsdkjfladjfgj12321

New Member
Joined
Jun 20, 2019
Messages
7
I am using VBA to make connections in Power Query, put a file name + extension in a cell, and rename the cell (Query1, Query2, Query3....). The macro runs fine. The part that I can't figure out is how to increment the variable in Power Query. It remains Query1 for connections that are made. It is hard coded in. I want to run the VBA be able to have the M code in each connection have Query1, then loop again to get Query2.

I hope what I described is clear.
 

Attachments

  • Power QUERY.JPG
    Power QUERY.JPG
    58.6 KB · Views: 38
  • Power Query2.JPG
    Power Query2.JPG
    53.8 KB · Views: 33
I would recommend you follow Sany666's suggestion. But to answer your question about appending the files Power Query should do that for you. The only proviso is that all the files have the same format; however, looking at your sample of code I suspect that is the case.
In my opinion VBA has limited use when you are using M language. I think you are trying to "push" data into PQ; let PQ do all the work from the "Get" point of view.
Peter
 
Upvote 0

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,223,748
Messages
6,174,264
Members
452,553
Latest member
red83

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top