VBA to Open a file with variable name and version

kevdragon1

New Member
Joined
Mar 8, 2021
Messages
21
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have an accounting software that produces reports. The software will name the excel reports for each store by their name and then add the version of each report. So for example, it will generate Store1_ver_1 today and tomorrow it will generate Store1_ver_2.

The goal of the macro will be to copy both versions for a store in a new excel file, in separate tabs. Version 2 would be in the tab called "Latest" and Version 1 would be in the tab called "Previous" of the same file.

I plan on creating a path on my computer and adding these 2 reports in that folder, run the macro, rinse and repeat for each store. I will be doing this for each store independently.

The problem is that, the version can be random example: version 6(latest) vs 4(previous). Another challenge is that the Store number can change, BUT at least the file names always end with "ver_x".

Can anyone help?

Thx
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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