Julmust Jaeger
New Member
- Joined
- Jul 20, 2022
- Messages
- 20
- Office Version
- 2016
- Platform
- Windows
Hello,
I have a three macros (see below) that I would like to run on every file in a folder (located at: H:\Accounts\C\2023\Dept).
All the files are in the .xlsx format.
Macro 1
Macro 2
Macro 3
I don't need to open the individual files, I would just like to have a way to run the code and then save the changes.
There are quite a few files (91) and some will generate around 20 worksheets using the copy/rename worksheet macro.
Thanks!
I have a three macros (see below) that I would like to run on every file in a folder (located at: H:\Accounts\C\2023\Dept).
All the files are in the .xlsx format.
Macro 1
VBA Code:
Sub PI_Funds()
Application.Calculation = xlCalculationManual
Application.DisplayStatusBar = False
Application.EnableEvents = False
Dim LR As Long, i As Long
Application.ScreenUpdating = False
With Sheets("Accounts")
LR = .Range("B" & Rows.Count).End(xlUp).Row
For i = 2 To LR
Sheets("Template").Copy after:=Sheets("Template")
ActiveSheet.Name = .Range("B" & i).Value
Next i
End With
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.DisplayStatusBar = True
Application.EnableEvents = True
End Sub
Macro 2
VBA Code:
Sub Replace_Formulas_with_Values()
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.EnableEvents = False
Dim ws As Worksheet
For Each ws In Worksheets
ws.Range("A:C").Value = ws.Range("A:C").Value
Next ws
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Application.DisplayStatusBar = True
Application.EnableEvents = True
End Sub
Macro 3
VBA Code:
'Delete Template, Reference, and Other Setup Worksheets and then Save
Sub Delete_Setup_Worksheets()
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.EnableEvents = False
Dim ws As Worksheet
For Each ws In Worksheets
If (ws.Name = "Accounts") Or (ws.Name = "2023") Or (ws.Name = "Template") Or (ws.Name = "Reference") Or (ws.Name = "Specific_Accounts") Then
Application.DisplayAlerts = False
Sheets(ws.Name).Delete
Application.DisplayAlerts = True
End If
Next ws
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Application.DisplayStatusBar = True
Application.EnableEvents = True
ActiveWorkbook.Save 'Save File
End Sub
I don't need to open the individual files, I would just like to have a way to run the code and then save the changes.
There are quite a few files (91) and some will generate around 20 worksheets using the copy/rename worksheet macro.
Thanks!