Name of sheet is based on cell value

ryan0521

Board Regular
Joined
Dec 7, 2016
Messages
79
Happy new year to all,

Can you help me to name sheets in workbook based on cell value specifically (J2).

Thank you in advance.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
May be
Code:
Sub Test()    Dim ws As Worksheet
    
    For Each ws In ThisWorkbook.Worksheets
        If ws.Range("J2").Value <> "" Then ws.Name = ws.Range("J2").Value
    Next ws
End Sub
 
Upvote 0
Try

Code:
Sub MM1()
ActiveSheet.Name = Range("J2").Value
End Sub
 
Upvote 0
Do you want it to automatically rename the sheet any time cell J2 is changed?
 
Upvote 0
Try this in worksheet module
Code:
Private Sub Worksheet_Change(ByVal Target As Range)    If Target.Address = "$J$2" Then
        Me.Name = Range("J2").Value
    End If
End Sub

Or if you need to apply on any sheet in the workbook try this in workbook module
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    If Target.Address = "$J$2" Then
        Sh.Name = Range("J2").Value
    End If
End Sub
 
Last edited:
Upvote 0
Place this in the sheet module

Private Sub worksheet_Change(ByVal target As Range)
If Intersect(target, Range("J2")) Is Nothing Then Exit Sub
If Range("J2").Value <> "" Then ActiveSheet.Name = Range("J2").Value
End Sub
 
Upvote 0
It works, but (J2) of sheet2 is link to sheet1 when I change the value of j2 in sheet1, sheet name for sheet1 changed but on sheet2 does not.
 
Upvote 0
I think maybe it's time you gave us ALL the required information....Each time we give you a solution, you move the goal posts !!
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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