Jun 15 2018
08:45 AM
- last edited on
Jul 31 2018
08:28 AM
by
TechCommunityAP
Jun 15 2018
08:45 AM
- last edited on
Jul 31 2018
08:28 AM
by
TechCommunityAP
I have 112 sheets and 112 names, I would like to rename all of the sheets. How can I do this?
Jun 15 2018 10:06 AM
SolutionHi 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 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
Jun 15 2018 11:39 AM
Thank you very much!!
Oct 23 2018 07:35 AM
How would you do the reverse? Capture the list of all the worksheet names.
Oct 23 2018 12:55 PM
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.
Sep 26 2019 12:48 PM
Can this macro be done with the Name in $B$2? @Haytham Amairah
Sep 26 2019 11:56 PM
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
Jun 12 2023 05:38 AM
How do you begin renaming sheets at Sheet 3? The first sheet is a summary sheet with a list project numbers I want to rename each sheet to and the second sheet is for rates. The list begins in Cell A2 and progresses downward. In addition, there will be two sheets per project: one for man hours and one for cost. For example, if cell A2 on the summary sheet contains the project number 12345, then Sheet 3's name would be 12345 Hrs and Sheet 4's name would be 12345 Cost. If cell A3 on the Summary sheet had 67890, the Sheet 5 would show 67890 Hrs and Sheet 6 would show 67890 Cost.
Jun 12 2023 05:48 AM
Jun 12 2023 06:16 AM
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?
Jan 02 2024 12:38 AM - edited Jan 02 2024 12:41 AM
I wondered the same thing. I eventually figured out you just change the J value and assign it to the sheet as (J) so it picked the right one. It's about 6 months too late for your question, but hopefully it'll help others that look here.
Sub Rename()
Dim J As Integer
Dim r As Integer
r = 1
J = 2
For Each Sheet In Sheets
J = J + 1
Sheets(J).Name = "Sheet" & J
On Error Resume Next
Next
J = 2
For Each Sheet In Sheets
J = J + 1
Sheets(J).Name = Cells(r, 1).Value
On Error Resume Next
r = r + 1
Next
End Sub
Jun 15 2018 10:06 AM
SolutionHi 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 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