Rename multiple sheets using a list

Jnagra88

New Member
Joined
Oct 22, 2018
Messages
4
Hi all,

Looking to rename multiple sheets based on a list located in worksheet 'codes' from the range B3:B35...

I hope someone can help!

Many thanks in advance
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Does the list contain the old and new names for the worksheets?
 
Upvote 0
No, it's literally just a list of numbers -

785005
785010
785015
785020
785030
785031
785050
785100
785105
785150
785165
785210
785230
785300
785305
785320
785325
785340
785350
785505
785510
785610
785615
785775
785810
786200
786400
786300

<colgroup><col></colgroup><tbody>
</tbody>
 
Upvote 0
So which sheet would be renamed with which number from the list?
 
Upvote 0
At present I only have one sheet which is called 'codes' with all those numbers on there. I need new sheets with those numbers if possible
 
Upvote 0
Does this work for you?

Code:
Sub AddWorkSheets()


For i = 3 To 35


    Sheets.Add After:=Worksheets(Worksheets.Count)
    Sheets(Worksheets.Count).Name = Sheets("Codes").Range("B" & i).Value
Next


End Sub
 
Upvote 0
So rather than rename existing sheets you want to add new sheets and use the list for their names?

Try this.
Code:
Dim wsCodes As Worksheet
Dim wsNew As Worksheet
Dim cl As Range

    Set wsCodes = Sheets("Codes")

    For Each cl in wsCodes.Range("B3", wsCodes.Range("B" & Rows.Count).End(xlUp)).Cells
        Set wsNew = ThisWorkbook.Sheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
        wsNew.Name = cl.Value
    Next cl
 
Upvote 0
Sorry, i meant add new sheets with the list of numbers.

The macro has worked, thank you everyone!
 
Upvote 0

Forum statistics

Threads
1,215,411
Messages
6,124,759
Members
449,187
Latest member
hermansoa

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