Loop through files, sort, save

jdk8008

New Member
Joined
May 2, 2015
Messages
11
Office Version
  1. 2019
Platform
  1. MacOS
Hello there,

I am looking for some help with what I perceive as a fairly simple loop function.

I have a Mac OS file directory structured like this:

Teams->49ers->player-stats.csv
Teams->Bears->player-stats.csv
Teams->Bengals->player-stats.csv

What I am looking to do is formulate a script that will open each team's player-stats.csv file, sort columns left to right A-Z, and save the file afterwards.

1. Macro excel file column-sorter.xls lives in the Teams directory
2. I open the file and execute the macro
3. It navigates from Teams to 49ers to open file player-stats.csv
4. Perform a left to right sort on row 1 A to Z
5. Save and close the file
6. Repeat steps 3-5 for all 32 teams

I am not great with excel VBA, so I would appreciate the help as the mismatched column ordering has been a very frustrating blocker for my project. Thanks!
 

Attachments

  • Screen Shot 2020-07-26 at 5.37.31 PM.png
    Screen Shot 2020-07-26 at 5.37.31 PM.png
    116.4 KB · Views: 9

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,215,063
Messages
6,122,934
Members
449,094
Latest member
teemeren

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