Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Prevent Sheet Rename

I have a number of protected sheets with macros doing various things. Is it
possible to disable the sheet rename function when right clicking a sheet
tab? If a user changes the sheet name then the macros will stop working as
they will be unable to find the sheets named within them.

Thanks for your help.

Nick
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Prevent Sheet Rename

Hi Nick,

you can protect the workbook to prevent user from changing name.

Regards,
Ivan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Prevent Sheet Rename

You may want to change your code to use the codename of the worksheet and let
the users rename the worksheet as they see fit.

If you look at project explorer within the VBE, you'll see the worksheets listed
under the Microsoft Excel Objects branch.

You'll see
Sheet1(whattheyseeinexcel)

The name in the ()'s is what the user sees in excel. The codename to the left
is what you can use in your code:

dim Wks as worksheet
set wks = worksheets("whattheyseeinexcel")
wks.range("a1").value = "hi"

could be replaced with:
sheet1.range("a1").value = "hi"

You could even rename the codename to something more significant (hit F4 to see
the properties of that worksheet and change the (Name) property to what you want
(still in the VBE).

=========
Alternatively, you could protect the workbook.
Inside Excel:
Tools|Protection|protect workbook|check structure

This will prevent the renaming of worksheets as well as
inserting/deleting/moving of them, too.

(Be aware that this kind of protection is easily broken.)

=========
The codename can be changed, too--but it's beyond most users.



Nick Smith wrote:

I have a number of protected sheets with macros doing various things. Is it
possible to disable the sheet rename function when right clicking a sheet
tab? If a user changes the sheet name then the macros will stop working as
they will be unable to find the sheets named within them.

Thanks for your help.

Nick


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Prevent Sheet Rename

Nick,

In your code, simply replace occurences of

Worksheets("Sheet Name")

with the worksheet's code name. When you see the worksheet in the Project Explorer, you'll see
something like

Sheet1 (SheetName)

Where SheetName is the name on the worksheet tab. In this case, the codename is Sheet1. You can
change the code name to something that makes sense within the code by changing it in the properties
window when you have the worksheet selected in the Project Explorer.


Worksheets("Sheet Name").Range("A1").Value ....

would become

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

Using this type of code allows the user to change the sheet name with no impact on your code.

HTH,
Bernie
MS Excel MVP


"Nick Smith" wrote in message
...
I have a number of protected sheets with macros doing various things. Is it
possible to disable the sheet rename function when right clicking a sheet
tab? If a user changes the sheet name then the macros will stop working as
they will be unable to find the sheets named within them.

Thanks for your help.

Nick



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i rename a sheet if the rename tab is inactive? Nelson Excel Worksheet Functions 1 March 3rd 10 10:28 AM
Move data to new sheet - rename sheet based on criteria ? [email protected] Excel Discussion (Misc queries) 7 May 16th 07 10:22 PM
How to copy a sheet and rename it with the value of two cells from the source sheet? Simon Lloyd[_717_] Excel Programming 0 May 12th 06 01:31 AM
Button to copy sheet, rename sheet sequencially. foxgguy2005[_3_] Excel Programming 9 June 17th 05 01:41 PM
prevent user to rename sheet caroline Excel Programming 4 May 17th 04 01:29 PM


All times are GMT +1. The time now is 04:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"