View Full Version : Don't to change name of sheets

12-30-2008, 02:16 PM

Someone can help me with this?

I have a Workbook and I do not want to change the name to the Sheets.


12-30-2008, 02:28 PM
Maybe, from menu Tools/Protection/Protect workbook/ check Structure and OK.

Is OK? :thumb


12-30-2008, 02:29 PM
I'm afraid I don't understand the question. Can you clarify your request?

12-30-2008, 02:47 PM
I'm afraid I don't understand the question. Can you clarify your request?

forgiveness for not explicitly state the question.

I have a workbook that has 3 sheets called
Cash Flow

What I want is that VBA is not permitted to change the name of the worksheets.


12-30-2008, 03:03 PM
If someone can run vba code in the workbook then this will be very hard to prevent.

Artik has suggested the only method that would come close but that prevents users from changing anything in the workbook.

Maybe I misunderstand still......is it possible that you want to protect the workbook or sheet using vba?

12-30-2008, 04:00 PM
There is one clever way to prevent this although it will seem absurd. You could write a naming macro for every possible event associated with the worksheet and then protect the vba editor/project with a password. See below.....

Private Sub Worksheet_Activate()
ThisWorkbook.Worksheets(1).Name = "Sheet1"
End Sub

Where "Activate" in the Private Sub title could be replaced by "Deactivate", "SelectionChange", "Change", etc,

This is just an off the top solution.....but remember that when you must protect the VBA code part of this workbook (the vba project).

Let me know if this works!

12-30-2008, 04:09 PM
Ischyros, that's a good idea.
Rather than using the index, which can be changed by moving sheets, the code name, which can't be changed, could be used.
Sheet1.Name = "Sheet1"

Its not clear to me that the OP wants to protect his workbook from VBA code. If he is only protecting himself against the user's keyboard and mouse, your routine (expanded to "rename" all sheets) could be put in ThisWorkbook's Workbook_SheetActivate event.