• 411K Members
• 6,012 Online
• 466K Conversations
SOLVED

## I would like to rename all the sheets from a list of names I have

Occasional 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?

6 Replies
Solution

# Re: I would like to rename all the sheets from a list of names I have

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    NextEnd Sub`

This 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 link to learn how to insert and run this code.

Regards

# Re: I would like to rename all the sheets from a list of names I have

Thank you very much!!

# Re: I would like to rename all the sheets from a list of names I have

How would you do the reverse? Capture the list of all the worksheet names.

# Re: I would like to rename all the sheets from a list of names I have

You would change

`Sheet.Name = Cells(r, 1).Value`

to

`Cells(r, 1).Value = Sheet.Name`

Please note:  This code  will overwrite any data that is in the cells in column A of the worksheet that is active when you run it.

# Re: I would like to rename all the sheets from a list of names I have

Can this macro be done with the Name in \$B\$2? @Haytham Amairah

# Re: I would like to rename all the sheets from a list of names I have

@teri_chow

Hi,

If you mean that the list of names starts from cell B2, you can change the code as follows:

``````Sub rename()
'Set the starting cell
Dim cell As Range
Set cell = Range("B2")

Dim r As Long
r = 0

For Each Sheet In Sheets
Sheet.Name = cell.Offset(r, 0)
r = r + 1
Next
End Sub``````

Regards

Related Conversations
flashing a white screen while open new tab
cntvertex in Discussions on
13 Replies
Tabs and Dark Mode
cjc2112 in Discussions on
22 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
28 Replies
description for autoplay blocking in settings page
HotCakeX in Discussions on
8 Replies