Forum Discussion
Hursh Patel
Jun 15, 2018Copper Contributor
I would like to rename all the sheets from a list of names I have
I have 112 sheets and 112 names, I would like to rename all of the sheets. How can I do this?
- Jun 15, 2018
Hi Hursh,
You can do this by using a VBA code!
But you need to have these name listed in a worksheet stating from cell A1 as follows:
Then you can depend on this code to rename all worksheets at once:
Sub rename()
Dim r As Integer
r = 1
For Each Sheet In Sheets
Sheet.Name = Cells(r, 1).Value
r = r + 1
Next
End SubThis code will loop through each worksheet and rename the Sheet1 with the name of cell A1, Sheet2 with the name of cell A2, and so on.
Please check this https://www.ablebits.com/office-addins-blog/2013/12/06/add-run-vba-macro-excel/ to learn how to insert and run this code.
Regards
mjohnston02090819
Jun 12, 2023Copper Contributor
When I use this exact code with the list of values shown, I get Run-time error '1004': Application-defined or object-defined error.
HansVogelaar
Jun 12, 2023MVP
Could you attach a small sample workbook demonstrating the problem (without sensitive data), or if that is not possible, make it available through OneDrive, Google Drive, Dropbox or similar?