How to run a macro simultaneously across multiple workbooks?
Running a macro across multiple workbook files can be time-consuming if you need to open each file individually. Fortunately, with VBA, you can execute a macro simultaneously on multiple workbooks without opening them. This tutorial provides a step-by-step guide to simplify this task in Excel.
Run a macro at same across multiple workbooks with VBA code
Run a macro at same across multiple workbooks with VBA code
To run a macro across multiple workbooks without opening them, please apply the following VBA code:
1. Hold down the "ALT + F11" keys to open the "Microsoft Visual Basic for Applications" window.
2. Click "Insert" > "Module", and paste the following macro in the "Module" Window.
VBA code: Run the same macro on multiple workbooks at same time:
Sub LoopThroughFiles()
Dim xFd As FileDialog
Dim xFdItem As Variant
Dim xFileName As String
Set xFd = Application.FileDialog(msoFileDialogFolderPicker)
If xFd.Show = -1 Then
xFdItem = xFd.SelectedItems(1) & Application.PathSeparator
xFileName = Dir(xFdItem & "*.xls*")
Do While xFileName <> ""
With Workbooks.Open(xFdItem & xFileName)
'your code here
End With
xFileName = Dir
Loop
End If
End Sub
Note: In the above code, please copy and paste your own code without the "Sub" heading and "End Sub" footer between the "With Workbooks.Open(xFdItem & xFileName)" and "End With" scripts. See screenshot:
3. Then press "F5" key to execute this code, and a "Browse" window is displayed, please select a folder which contains the workbooks that you want to all apply this macro, see screenshot:
4. Click "OK", the desired macro will be executed across all selected workbooks.
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
All Kutools add-ins. One installer
Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.





- All-in-one suite ā Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
- One installer, one license ā set up in minutes (MSI-ready)
- Works better together ā streamlined productivity across Office apps
- 30-day full-featured trial ā no registration, no credit card
- Best value ā save vs buying individual add-in