Automating Tab names

S

Stilla

Hi.. On this site, I found this VBA code for naming tabs with entry in a
particular cell, but it's not working... I only changed the "a2" part to
correspond to my particular case, and left everything else alone. What
could be wrong?
__________
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
ActiveSheet.Name = Range("a2").Value
End Sub
___________

Thanks in advance
 
B

Bob Phillips

That code needs to be in the Thisworkbook code module, and it should be

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Address = "$A$2" Then
sh.Name = Target.Value
End If
End Sub


--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)
 
O

Otto Moehrbach

Stilla
Not sure of what you want to do. I think you want the name of each
sheet to change to the value of A2 when that sheet is selected (activated).
If this is so use this: Post back if this is not what you want. HTH
Otto
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
ActiveSheet.Name = Range("a2").Value
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

Top