Running Macros on multiple files

cturner1975

New Member
Joined
Nov 19, 2010
Messages
11
Hi,

I have a large number of excel files that I need to run certain macros everyday. I have all the macros save on one excel file. Is there a way to select all the excel files that I want to run the macros, rather than me having to open each excel file and run one by one? This will be a big time saver for me.

Can someone please help me with this? Thanks!

Here is one of the marco that I use regularly:

Sub Prop_AB()
Dim LR As Long, cell As Range
LR = Range("A" & Rows.Count).End(xlUp).Row
For Each cell In Range("A1:B" & LR)
cell.Value = StrConv(cell.Value, vbProperCase)
Next cell
End Sub
 
Last edited:

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
You will need to open each file then run the code. Take a look at Dir inthe VBA help.
 
Upvote 0
If you put all the filepaths in a list, you could loop through the list calling the approppriate macros. For example if you put 10 filepaths in column A

Code:
Dim iCount as Integer
Dim sApp As String
Dim sTarget As String
sApp = ActiveWorkbook.Name
 
For iCount = 1 To 10
    Workbooks.Open Workbooks(sApp).Sheets(1).Cells(iCount, 1).Value
    sTarget = ActiveWorkbook.Name
 
    Call Prop_AB
 
    Workbooks(sTarget).Close savechanges:=True
Next iCount
Workbooks(sApp).Activate
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,285
Members
452,902
Latest member
Knuddeluff

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