How to Import Multiple CSV Files from a Folder in Excel for Mac Using VBA
Question details
The user needs to automate the process of importing and merging multiple CSV files stored in a single folder into one master workbook on a Mac.

- Product
- Microsoft Excel
- Device & OS
- macOS
- Scenario
- Consolidating data from multiple CSV files into a single Excel workbook on a Mac computer.
- Observed behavior
- Excel for Mac lacks the Windows-style "Get Data > From File > From Folder" Power Query feature, forcing users to rely on VBA scripts to automate file merging.
Ensure all the CSV files you want to merge are saved in a single, dedicated folder on your Mac, and that they share the exact same column structure to prevent data misalignment.
Use a Mac-Compatible VBA Macro to Loop and Merge CSV Files
Write and execute a VBA macro specifically tailored for macOS to loop through a folder, open each CSV file, and copy its contents into a master workbook.
Because macOS handles file systems differently than Windows, standard Windows VBA scripts using FileSystemObject will not work. You must use a Mac-compatible VBA script that leverages AppleScript or Mac-specific directory looping to iterate through the folder.
Launch Excel for Mac, open a new blank workbook (your master workbook), and press Option + F11 to open the Visual Basic for Applications (VBA) Editor.
In the VBA Editor menu, click Insert > Module. This creates a blank space where you can paste your macro code.
Paste a VBA script designed for Mac Excel automation (such as those provided by MacExcel.com for merging workbooks). Ensure the script uses Mac directory separators (colons or forward slashes depending on your Office version).
Locate the path variable in the pasted code and replace it with the actual path to your CSV folder (e.g., "Macintosh HD:Users:YourName:Desktop:CSVFolder:").
Click anywhere inside the macro code and press F5, or click the Run button. The script will sequentially open each CSV file in the folder, copy the data, paste it into your master workbook, and close the source file.

Try WPS Office for Seamless Spreadsheet Management on Mac
Struggling with missing or complicated features in Excel for Mac? WPS Office is a free, lightweight, and highly compatible alternative that makes managing, importing, and analyzing your spreadsheet data incredibly easy on macOS.
- 1. Download WPS Office for Mac: Visit the official WPS website and download the macOS version of WPS Office.
- 2. Install and Launch: Follow the simple installation prompts, then open WPS Spreadsheet on your Mac.
- 3. Manage Your Data Effortlessly: Open your CSV or Excel files natively and enjoy a robust set of data manipulation tools without worrying about complex VBA setups.

Frequently Asked Questions
Why is the "Get Data from Folder" feature missing in Excel for Mac?
Microsoft has not fully ported the complete Power Query feature set to Excel for Mac. While recent updates have added basic Power Query capabilities, importing directly from a folder remains a Windows-exclusive feature, requiring Mac users to use VBA or AppleScript workarounds.
Can I use Windows VBA scripts to merge CSV files on my Mac?
Generally, no. Windows VBA often relies on the Scripting.FileSystemObject or specific Windows directory commands which do not exist on macOS. You must use Mac-specific VBA functions or AppleScript integrations to handle file and folder looping.
Is there a non-VBA way to combine CSV files on a Mac?
Yes, you can use the macOS Terminal. Open Terminal, navigate to your folder using the 'cd' command, and type 'cat *.csv > combined.csv'. This instantly merges all text data into a single file, though you may need to open it in Excel afterward to delete repeating header rows manually.




