ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   prevent change sheet name (https://www.excelbanter.com/excel-programming/333568-prevent-change-sheet-name.html)

helmekki[_80_]

prevent change sheet name
 

Hi there

Is there a code to protect the name of sheets ?

i donot want to let users change the name of the worksheets


--
helmekki


------------------------------------------------------------------------
helmekki's Profile: http://www.excelforum.com/member.php...fo&userid=6939
View this thread: http://www.excelforum.com/showthread...hreadid=384357


Jim Thomlinson[_4_]

prevent change sheet name
 
Nope there is no way to stop the user from changing the sheet tab names. You
can either train all of your users to never change the tab names or you can
write code that does not refer to the tab name (this is my prefered method).
Instead of refering to the sheet
Sheets("Sheet1").Select
change it to
Sheet1.Select

Note that you can change the code name of the sheet in the properties window
to something more appropriate than Sheet1 like shtMySheet by changing the
value beside (Name).
--
HTH...

Jim Thomlinson


"helmekki" wrote:


Hi there

Is there a code to protect the name of sheets ?

i donot want to let users change the name of the worksheets


--
helmekki


------------------------------------------------------------------------
helmekki's Profile: http://www.excelforum.com/member.php...fo&userid=6939
View this thread: http://www.excelforum.com/showthread...hreadid=384357



Nick Hodge

prevent change sheet name
 
Helmekki

Is this because you are referring to them in code? If so then use the
CodeName. This can be set at design time (easy) or runtime (more tricky)
and they can't be changed from the UI

E.g if you set the codename for a sheet to Sheet1 (default for sheet 1) you
can refer to it as

Sheet1.Range("A1").Value=12345

It then doesn't matter what the tab name is

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"helmekki" wrote in
message ...

Hi there

Is there a code to protect the name of sheets ?

i donot want to let users change the name of the worksheets


--
helmekki


------------------------------------------------------------------------
helmekki's Profile:
http://www.excelforum.com/member.php...fo&userid=6939
View this thread: http://www.excelforum.com/showthread...hreadid=384357




Norman Jones

prevent change sheet name
 
Hi Helmekki,

i donot want to let users change the name of the worksheets


Why not?

If you use the sheets' code names for manipulation purposes, any user change
to a sheet name should not adversely affect you, the developer.

In any event, any moderately savvy Excel user knows that a sheet can be
renamed. Why, therefore, seel to engender user animosity unnecessarily?

---
Regards,
Norman



"helmekki" wrote in
message ...

Hi there

Is there a code to protect the name of sheets ?

i donot want to let users change the name of the worksheets


--
helmekki


------------------------------------------------------------------------
helmekki's Profile:
http://www.excelforum.com/member.php...fo&userid=6939
View this thread: http://www.excelforum.com/showthread...hreadid=384357




LenB[_3_]

prevent change sheet name
 
If you are going to refer to them by their codename as other have
smartly suggested, always change the codename to something other than
the default. Here's the catch (tested in Excel97). Say you have three
sheets and your program refers to codename "Sheet2". Somehow sheet2
gets deleted and a new sheet added. Tha tab name will be Sheet4, but
the code name will be Sheet2. Probably not the sheet2 that your program
refers to.

If you don't want a sheetname to change, try checking the name in the
worksheet activate and/or deactivate events, and change it back if it
has changed. Not perfect, but maybe it will work for you.

Len

helmekki wrote:
Hi there

Is there a code to protect the name of sheets ?

i donot want to let users change the name of the worksheets



JMB

prevent change sheet name
 
If you do try to the sheet activate/deactivate route, you will also need to
capture the active sheet name when the workbook is opened. Otherwise the
user could change the sheet name of whatever sheet is active when the
workbook is first opened.


"LenB" wrote:

If you are going to refer to them by their codename as other have
smartly suggested, always change the codename to something other than
the default. Here's the catch (tested in Excel97). Say you have three
sheets and your program refers to codename "Sheet2". Somehow sheet2
gets deleted and a new sheet added. Tha tab name will be Sheet4, but
the code name will be Sheet2. Probably not the sheet2 that your program
refers to.

If you don't want a sheetname to change, try checking the name in the
worksheet activate and/or deactivate events, and change it back if it
has changed. Not perfect, but maybe it will work for you.

Len

helmekki wrote:
Hi there

Is there a code to protect the name of sheets ?

i donot want to let users change the name of the worksheets




jose luis

prevent change sheet name
 

Another ways is to protect the tabs via Workbook protection (Tools /
Protection / Protect WorkBook) manually.


Code:
--------------------
via code use ActiveWorkbook.protect [password:="Pepe" (opcional)]
ActiveWorkbook.unprotect [password:="Pepe" (opcional)]
--------------------



Hope this helps you

Jose Luis


--
jose luis
------------------------------------------------------------------------
jose luis's Profile: http://www.excelforum.com/member.php...o&userid=13312
View this thread: http://www.excelforum.com/showthread...hreadid=384357



All times are GMT +1. The time now is 07:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com