View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default Trap Sheet Name Change


This might work...

Code must reside in Thisworkbook's codemodule.
It will check if the name is different from the CODENAME
(the name you see in VBeditor project explorer.)

First change all the Codenames to be equal the sheet name
(note that codenames cannot contain spaces..
if that is a problem you could do a simple REPLACE
or use underscores iso spaces.)

it will trigger very often so keep it simple!


Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal
Target As Range)
If Not TypeOf Sh Is Worksheet Then Exit Sub
If Sh.Name < Sh.CodeName Then
MsgBox "Sheet renaming NOT allowed"
Sh.Name = Sh.CodeName
End If
End Sub



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Otto Moehrbach" wrote:

Frank
That event macro doesn't fire when the sheet name is changed.
Thanks
anyway. If you have any other ideas please send them.
My objective is to trap the event and, if necessary, bring the old
sheet
name back. This latter part appears to be a major problem because the
Undo is not triggered when the user changes the tab name. Otto
"Frank Kabel" wrote in message
...
Hi
try the worksheet_calculate event

--
Regards
Frank Kabel
Frankfurt, Germany


Otto Moehrbach wrote:
Excel 2002, WinXP
Is there any way to trap the event (fire an event macro) of a user
changing a sheet tab name?
The Worksheet_Change macro doesn't fire with this change.
Thanks for your help. Otto