"This is the way..." to merge data (multiple files into one) - PowerQuery? VBA? ...?

CaptnAbraham

New Member
Joined
Feb 10, 2022
Messages
14
Office Version
  1. 2019
Platform
  1. Windows
Dear people of the world~

It is a questions surely asked many a times... and answered a few times.
I have received, from a third party, some 200+ inspection reports of apartments. Each apartment is one Excel file with one Sheet in them (but named differently).
The two photo snippets show the beginning and the end of one of the files.

My task would be to merge all the relevant / recorded data (yellow cells) into a table. Unfortunately this third party's report is not very data-friendly...
In my olden days I would...
a) open one of the files and copy the future header information (in this case column B mostly, but not exclusively, there are also sub-fields as well in the following columns this time around...) into a new file,
b) link the two files / data entry cells together into one row (here: yellow) for all x-hundred cells (into new columns)
c) copy the finished row and use the replace button to... replace the file name with the next one
d) repeat b)+c) for as many times as needed

This can't be the future... I have tried to use PowerQuery and I could load the files no problem... but it's a mess obviously. Cleaning it up, while I'm able to do basic things with normal data sets, is in this case over my head. Is it even possible? Would VBA be a better solution for this? It's close to 600 individual cells... I don't have the imagination how to even start on that (though I guess if the task for one cell is repeatable, I would have to simply replicate that code... 600 times... and be done with it?).

Any pointers on what to use to automate such a task? If an example then on how to do that is at your hands, that would be heavenly.

Cheers and thanks for reading through my ramble, haha.
 

Attachments

  • ABC_28_00_li_Testfile01_beginning.PNG
    ABC_28_00_li_Testfile01_beginning.PNG
    110.7 KB · Views: 19
  • ABC_28_00_li_Testfile01_end.PNG
    ABC_28_00_li_Testfile01_end.PNG
    99.4 KB · Views: 25

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Alright... After four hours of searching I'm taking the first baby steps. Here is a part of it... it goes on a bit longer in its original state as there are 600 cells to copy.
With that I'm able to gather the information of one sheet.

Next step: Finding a way to change the filename and output-/range-row (so far still using the replace button to change the code).


Sub DataGathering()
'
Range("C4").Select
Selection.FormulaR1C1 = "=[Filename.xlsx]EG_re!R3C2"
Range("D4").Select
Selection.FormulaR1C1 = "=[Filename.xlsx]EG_re!R3C4"
Range("E4").Select
Selection.FormulaR1C1 = "=[Filename.xlsx]EG_re!R3C8"
Range("F4").Select
Selection.FormulaR1C1 = "=[Filename.xlsx]EG_re!R3C10"
Range("G4").Select
Selection.FormulaR1C1 = "=[Filename.xlsx]EG_re!R5C3"
Range("H4").Select
Selection.FormulaR1C1 = "=[Filename.xlsx]EG_re!R5C5"
Range("I4").Select
Selection.FormulaR1C1 = "=[Filename.xlsx]EG_re!R5C6"
Range("J4").Select
Selection.FormulaR1C1 = "=[Filename.xlsx]EG_re!R5C7"
Range("K4").Select
Selection.FormulaR1C1 = "=[Filename.xlsx]EG_re!R5C9"
Range("L4").Select
Selection.FormulaR1C1 = "=[Filename.xlsx]EG_re!R5C11"
Range("M4").Select
Selection.FormulaR1C1 = "=[Filename.xlsx]EG_re!R6C3"
Range("N4").Select
Selection.FormulaR1C1 = "=[Filename.xlsx]EG_re!R6C6"
Range("O4").Select
Selection.FormulaR1C1 = "=[Filename.xlsx]EG_re!R6C8"
Range("P4").Select
Selection.FormulaR1C1 = "=[Filename.xlsx]EG_re!R6C10"
Range("Q4").Select
Selection.FormulaR1C1 = "=[Filename.xlsx]EG_re!R7C3"
Range("R4").Select
Selection.FormulaR1C1 = "=[Filename.xlsx]EG_re!R7C6"
Range("S4").Select
Selection.FormulaR1C1 = "=[Filename.xlsx]EG_re!R7C9"
Range("T4").Select
Selection.FormulaR1C1 = "=[Filename.xlsx]EG_re!R8C3"
Range("U4").Select
Selection.FormulaR1C1 = "=[Filename.xlsx]EG_re!R10C3"
Range("V4").Select
Selection.FormulaR1C1 = "=[Filename.xlsx]EG_re!R10C6"
Range("W4").Select
Selection.FormulaR1C1 = "=[Filename.xlsx]EG_re!R10C8"
Range("X4").Select

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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