• 545K Members
• 6,545 Online
• 651K Conversations
SOLVED

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

Highlighted
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

Highlighted

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

Thank you very much!!

Highlighted

# 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.

Highlighted

# 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.

Highlighted

# 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

Highlighted

# 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
SharePoint Lists - Expanded View Roadmap ID: 57302
Kotus-Tech in SharePoint on
9 Replies
Multi-value fields display no separator
Florian Hein in SharePoint on
1 Replies
A problem with the Zoom level of a Tab
Tavory in Discussions on
9 Replies
Rename device name for Surface Hub
Petri X in Surface Hub on
1 Replies
PWA fullscreen like IE11 kiosk mode
rogihee in Discussions on
5 Replies