Rename worksheet in multiple Excel files within a folder

Lcsuther

New Member
Joined
Sep 10, 2018
Messages
3
HI,

I have a folder that contains about 30 Excel files. Each file has only one worksheet which is named the same as the file name, Which is a monthly export by month. I need the worksheet name in each file to read "Balance Sheet". How can I change all the worksheet names in 30 files at once?

Thank you, LC
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
try this
VBA Code:
Sub OPEN_ALL_FILES_IN_FOLDER_RUN_MACRO()

Dim Path As String
'path to your folder with excel files
Path = "C:\Users\xxxxx\Desktop\folder name\"
Dim fileName As String

' ANY EXCEL FILE
fileName = Dir(Path & "*.xls*")

Application.DisplayStatusBar = False
Application.EnableEvents = False
Application.ScreenUpdating = False
Application.DisplayAlerts = False

Do While fileName <> ""
Workbooks.Open Path & fileName

' *****************************************************add code to run on each workbook in the folder********************************************
   ActiveSheet.Name = "Balance Sheet"
' ****************************************************end code to run on each workbook in the folder*********************************************
Workbooks(fileName).Close True
fileName = Dir()
Loop
Application.DisplayStatusBar = True
Application.EnableEvents = True
Application.ScreenUpdating = True
Application.DisplayAlerts = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,561
Messages
6,120,242
Members
448,951
Latest member
jennlynn

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