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

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
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,215,056
Messages
6,122,907
Members
449,096
Latest member
dbomb1414

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