Protecting Worksheet Names

G

Guest

I would like VBA code to protect a worksheet from being RENAMED - pls don't
confuse this and tell me how to protect a worksheet as I already know that.

My application works so long as users don't go changing sheet names. Can
anyone help me?

Thnx
 
N

Norman Jones

Hi Hoppermr,
My application works so long as users don't go changing sheet names. Can
anyone help me?

Try changing your code to use the sheet code name instead of the sheet name.
If the user changes the sheet name, the code name remains unaltered.
 
A

Arvi Laanemets

Hi

Instead protecting worksheet, have you tried to protect workbook structure?
It looks like you need just this!
(Tools>Protection>Protect Workbook, and check 'Structure')
 
G

Guest

use the sheet object name.
OPen a new workbook, change the tab name of a sheet to say "Data"
Now look in the IDE for the Project Explorer (Ctrl+R). You'll seesomething
like Sheet1(Data)
select it and view the properties window (F4)
in Properties you'll see the property called (name) which is the object
name, eg Sheet1 and you'll see the Name property has a value Data, the
sheet's name.
change t he object's (name) property to say shData

now, in your code, instead of using, for example
WITH Worksheets("Data")
use
WITH shData

It won't matter if your user changes the tab name (sheet name), the object
name can only be changed through the IDE.
 

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