Macro forr Worksheet names

  • Thread starter Thread starter Jim
  • Start date Start date
J

Jim

Is it possible to use a cell refrence to name the
worksheet tab or do you need a macro??
 
Jim

You need a macro.

Sub SheetName()
ActiveSheet.Name = Range("c1")
End Sub

Gord Dibben Excel MVP
 
Hi
and if you want to automatically change the tab name if you change the
cell value put the following code in your worksheet module (not in a
standard module):

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("A1")) Is Nothing Then Exit Sub
On Error GoTo CleanUp
application.enableevents = false
With Target
If .Value <> "" Then
Me.Name = .value
End If
End With
CleanUp:
Application.EnableEvents = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top