Donot allow user to change name of the worksheet

P

Pawan

Hi

I have a workbook with several sheets in it. However I donot want anyone to
change name of one worksheet named 'Data'. He can rename other sheets. Is it
possible to prevent user from changing name of one sheet?

(This is because my macro will delete all sheets except the one with name
'Data'. If user changes name of 'Data' sheet, tehn macro will delete it!)

Thank You
Pawan
 
M

Mike H

Hi,

there's no sheetname_change event but there are several workarounds. One way
would be to look at your macro and use codename instead of name. While the
codename can be changed its fairly safe and of course you do have a backup
don't you. the example below assumes you sheet named "Data" has a codename of
sheet1

For Each Worksheet In Sheets
'If worksheet.Name <> "Data" Then
If Worksheet.CodeName <> "Sheet1" Then
Worksheet.Delete
End If
Next Worksheet


Mike
 
P

Pawan

It worked...

Thanks Mike.. :)

Mike H said:
Hi,

there's no sheetname_change event but there are several workarounds. One way
would be to look at your macro and use codename instead of name. While the
codename can be changed its fairly safe and of course you do have a backup
don't you. the example below assumes you sheet named "Data" has a codename of
sheet1

For Each Worksheet In Sheets
'If worksheet.Name <> "Data" Then
If Worksheet.CodeName <> "Sheet1" Then
Worksheet.Delete
End If
Next Worksheet


Mike
 

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