View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default *How can you rename a tab based on a cell value

Yes.....that works but this doesn't

Private Sub Worksheet_Calculate()
Const WS_RANGE As String = "A1" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Me.Name = .Value
End With
End If

ws_exit:
Application.EnableEvents = True

End Sub

If I REM out the On Error GoTo line, I throw an error on

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then

Something here I just don't understand with my limited knowledge of events.


Gord

On Sun, 3 Dec 2006 01:06:48 -0000, "Bob Phillips" wrote:

Hi Gord,

Just do it in Calculate.

Private Sub Worksheet_Calculate()
Me.Name = Range("A1").Value
End Sub

Of course it does mean it happens for every formula/value change that will
trigger a calculate.


Gord Dibben MS Excel MVP