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: 23
  • Power Query2.JPG
    Power Query2.JPG
    53.8 KB · Views: 23
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

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,214,923
Messages
6,122,286
Members
449,076
Latest member
kenyanscott

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