Append all sheets within file, then all files within folder PowerQuery

Craigc3814

Board Regular
Joined
Mar 7, 2016
Messages
217
I have a spreadsheet that my company gets monthly for usage. The spreadsheet has 4 worksheets in it. East, West, Central, RTC. I am using Ken Puls FnGetContents function to pull in each one separately (so I created the function 4 times). Then I append them all after the fact. Is there a way to clean the spreadsheet up and have the FnGetContents only run 1 time, append each worksheet in a workbook then append all workbooks in the folder?
Here is one of my FnGetContents functions

(filepath)=>
let
Source = Excel.Workbook(File.Contents(filepath)),
EAST1 = Source{[Name="EAST"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(EAST1),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Usage(Gallons)", type number}, {"Available (Gallons)", type number}, {"Level (Ft)", type number}})
in
#"Changed Type"
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Your function takes a single input parameter (filepath). But you can pass more parameters. E.g. (Filepath, Region)

so change the line east1 so it accepts the region as a parameter. The. Get a table of all the sheets (regions) and pass them to the function.
 
Upvote 0
Just create a table with each worksheet name in 1 row. Then add a column where you call the function, referencing the first column for the parameter.
If you expand that column, all sheets will automatically be appended. No need for a separate append-function then.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,212
Members
452,618
Latest member
Tam84

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