logo
search
Data Import & Export

How to Import Multiple CSV Files from a Folder in Excel for Mac Using VBA

Phi Hung VoPhi Hung Vo Oct 20, 2026 869 views

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.

How to Import Multiple CSV Files from a Folder in Excel for Mac Using VBA
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the VBA Editor

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.

2
Insert a New Module

In the VBA Editor menu, click Insert > Module. This creates a blank space where you can paste your macro code.

3
Paste the Mac-Specific Merge 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).

4
Update the Folder Path

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:").

5
Run the Macro

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.

Use a Mac-Compatible VBA Macro to Loop and Merge CSV Files
Getting the Correct Folder Path: To easily find your folder path on a Mac, right-click the folder in Finder, hold down the Option key, and select "Copy [Folder Name] as Pathname".
Free Microsoft Office alternative

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. 1. Download WPS Office for Mac: Visit the official WPS website and download the macOS version of WPS Office.
  2. 2. Install and Launch: Follow the simple installation prompts, then open WPS Spreadsheet on your Mac.
  3. 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.
Fully compatible with Microsoft Excel formats (.xlsx, .csv, .xls) ensuring no data loss.Lightweight application that runs smoothly and efficiently on macOS without draining resources.Familiar, intuitive tabbed user interface requiring zero learning curve.Built-in powerful data processing and consolidation tools for everyday tasks.
microsoft office alternative - wps office

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.