Naming a sheet/tab by refering to a cell

davey11372

Board Regular
Joined
Dec 19, 2009
Messages
56
I have a workbook with a hundred sheets.

I want each sheet in the workbook to be named by reference to the value of cell A1 in each sheet.

How can I do this.

What script/code do I need and where do I paste it?

Thanks
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Press ALT + F11 to open the Visual Basic Editor, select Module from the Insert menu and paste into the white space on the right

Code:
Sub NameSheets()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
    With ws
        .Name = .Range("A1").Value
    End With
Next ws
End Sub
.

Press ALT + Q to close the code window, Tools > Macro > Macros, click on NameSheets and click the Run button.
 
Upvote 0
Thanks much. It worked like a charm.

VoG, I have another post title "Sorting an Array Formul" .. would you have a solution to that?

Thanks again.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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