VBA Macro to open specific files from subfolder

jacekbn

New Member
Joined
Aug 5, 2015
Messages
1
Hi Guys,

Since it's my first post on this forum I wanted to thanks everyone for the tremendous amount of help I have received from reading all the threads.

I do however have one small VBA problem that I am stuck on for the past few days and could not find help by checking these boards or googling.

Here is the issue:

I have a file that contains the macro, lets call it Master_File.

In the folder with Master_File, there are ~10 subfolders, with different files within each subfolder.

Only 1 of the files within each subfolder is has a filename that ends with "final.xlsx" (for example, therey maybe 2 files inside a subfolder, "123.xlsx" and "123_final.xlsx").

I need a macro that will collect the data from each of the "final" files and consolidate into the master DB. I can handle the process of data consolidation just fine but I having huge troubles creating a macro that will search each of these folders for their specific "final".

As a small additional request. In order for me to have it a bit easier, could you please help me with setting sheet(1) of each of the final file as a variable named "okr".

Below I'm posting the simple consolidation part:

Code:
okr.Range("A8:AV" & Cells(Rows.Count, "A").End(xlUp).Row).Copy

ost = ThisWorkbook.Sheets(1).Range("A" & Rows.Count).End(xlUp).Row

ThisWorkbook.Sheets(1).Range("A" & ost + 1).PasteSpecial xlPasteValues

Any help would be really appreciated.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,215,660
Messages
6,126,082
Members
449,286
Latest member
Lantern

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