Disable Select Cells Q

  • Thread starter Thread starter Sean
  • Start date Start date
S

Sean

I have the following code, which I though would stop the ability of the
user to select locked cells, but it doesn't. It protects my sheet, but
user can still select cells. Do I have something wrong?


Sheets("E-Mail").Activate
ActiveSheet.EnableSelection = xlNoSelection
ActiveSheet.Protect Password:="1234"
 
Sean,
You code works for me.
But ActiveSheet.EnableSelection is not a persistent property; you have to
set it every time the file is opened, may in the Workbook_Open() event.

NickHK
 
There's no need to Select or Activate the sheet (or anything else, for that
matter), and doing so may have unintended consequences (e.g., the rest of
the procedure may rely on a particular sheet being active).

Instead, use code like

With Sheets("E-Mail")
.Protect
.EnableSelection = xlUnlockedCells
End With


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
 
The code worked yesterday, using Office 2003, but now today with
another user using Office 2000 it hasn't. Is the code not supported in
Office 2000?
 
It should work in all versions since at least 97, as far as I know.
Specifically what do you mean by "doesn't work"? Details count.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
 
Chip, if I run the code on my PC (Excel 2003) I can't select cells in
the relevant sheet, but another person runs it from their PC (Excel
2000) and you can select cells.

I also notice that on one sheet of this workbook the .DisplayGridlines
= False is not activated (but it is when I run it - part of the same
code)

I've even recorded a macro (on the 2000 PC) to remove the
ActiveSheet.EnableSelection = xlUnlockedCells and it works, yet when
the particular code I'm running is run, no such luck

Must sheets be visible when .EnableSelection = xlUnlockedCells is run?
 

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

Similar Threads

Drawn Objects Q 2
Auto-Protect Sheet on Open and on Close 3
Not Select locked cells 0
Sheet protection 1
Protect a Workbook 3
Protect a sheet 3
Password Protect Worksheet 4
Protect via Code Q 3

Back
Top