Worksheet Tabs

Mldeuser

Well-known Member
Joined
Dec 27, 2008
Messages
573
Office Version
  1. 365
Platform
  1. Windows
Is it possible to lock the tabs so they can not be renamed??

Thanks
Mark
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
hI

Tools>Protection>Protect Workbook. You can apply a password to this too but please note that workbook protection (like worksheet protection) is not terribly robust and will prevent no obstacle to a determined user (but will serve to deter causal users from changing your sheet names).
 
Upvote 0
Just a thought. Are you requesting this because you use the Sheet names in code and when they are changed, the code errors? If so, you can avoid this by using Index numbers in your code instead of Names. So instead of
Code:
WorkSheets("Mary").Range....
use
Code:
WorkSheet(3).Range... or
Sheet3.Range...
Now it will usually not matter if a user renames a sheet.
lenze
 
Upvote 0
That was the reason. I will try what you suggested

Thanks
 
Upvote 0
An even more secure way would be to use the sheet's code name in code, as the index will potentially change if a user moves a sheet, or deletes/inserts one.

The sheet's code name is the name in the VBE in the Properties Window of the sheet next to the (Name) field (so you can also change it in this window too). Somewhat confusingly, it is also the name that doesn't appear in brackets in the top left Project Window of the VBE for the sheet. If you use that in code, then you won't have to worry about users changing order or sheet names from the user interface (ie Excel itself) as the code name does not change:

Rich (BB code):
'refer to sheets via CodeName:

Sheet2.Range("A2:A10").Formula = "=RAND()"

'text in red above is the code name (as determined from the properties window of the worksheet in question)
 
Upvote 0
Thanks for that bit of information as some of the user do reorder the worksheets.

Mark
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,521
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top