PC Review


Reply
Thread Tools Rate Thread

Disable Select Cells Q

 
 
Sean
Guest
Posts: n/a
 
      17th Jan 2007
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"

 
Reply With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      17th Jan 2007
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

"Sean" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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"
>



 
Reply With Quote
 
Sean
Guest
Posts: n/a
 
      17th Jan 2007
Thanks Guys, your option worked Mike


Mike wrote:
> try
>
> Sheets("E-Mail").Activate
> ActiveSheet.protect
> ActiveSheet.EnableSelection = xlUnlockedCells
>
> Mike
> "Sean" wrote:
>
> > 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"
> >
> >


 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      17th Jan 2007
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)



"Mike" <(E-Mail Removed)> wrote in message
news:E679602B-97AC-4D32-9F0D-(E-Mail Removed)...
> try
>
> Sheets("E-Mail").Activate
> ActiveSheet.protect
> ActiveSheet.EnableSelection = xlUnlockedCells
>
> Mike
> "Sean" wrote:
>
>> 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"
>>
>>



 
Reply With Quote
 
Sean
Guest
Posts: n/a
 
      18th Jan 2007
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?



Chip Pearson wrote:
> 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)
>
>
>
> "Mike" <(E-Mail Removed)> wrote in message
> news:E679602B-97AC-4D32-9F0D-(E-Mail Removed)...
> > try
> >
> > Sheets("E-Mail").Activate
> > ActiveSheet.protect
> > ActiveSheet.EnableSelection = xlUnlockedCells
> >
> > Mike
> > "Sean" wrote:
> >
> >> 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"
> >>
> >>


 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      18th Jan 2007
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)


"Sean" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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?
>
>
>
> Chip Pearson wrote:
>> 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)
>>
>>
>>
>> "Mike" <(E-Mail Removed)> wrote in message
>> news:E679602B-97AC-4D32-9F0D-(E-Mail Removed)...
>> > try
>> >
>> > Sheets("E-Mail").Activate
>> > ActiveSheet.protect
>> > ActiveSheet.EnableSelection = xlUnlockedCells
>> >
>> > Mike
>> > "Sean" wrote:
>> >
>> >> 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"
>> >>
>> >>

>



 
Reply With Quote
 
Sean
Guest
Posts: n/a
 
      19th Jan 2007
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?




Chip Pearson wrote:
> 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)
>
>
> "Sean" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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?
> >
> >
> >
> > Chip Pearson wrote:
> >> 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)
> >>
> >>
> >>
> >> "Mike" <(E-Mail Removed)> wrote in message
> >> news:E679602B-97AC-4D32-9F0D-(E-Mail Removed)...
> >> > try
> >> >
> >> > Sheets("E-Mail").Activate
> >> > ActiveSheet.protect
> >> > ActiveSheet.EnableSelection = xlUnlockedCells
> >> >
> >> > Mike
> >> > "Sean" wrote:
> >> >
> >> >> 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"
> >> >>
> >> >>

> >


 
Reply With Quote
 
Sean
Guest
Posts: n/a
 
      20th Jan 2007
I again tested this same code this AM and it works when running on 2003
but not on 2000


Sean wrote:

> 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?
>
>
>
>
> Chip Pearson wrote:
> > 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)
> >
> >
> > "Sean" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > 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?
> > >
> > >
> > >
> > > Chip Pearson wrote:
> > >> 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)
> > >>
> > >>
> > >>
> > >> "Mike" <(E-Mail Removed)> wrote in message
> > >> news:E679602B-97AC-4D32-9F0D-(E-Mail Removed)...
> > >> > try
> > >> >
> > >> > Sheets("E-Mail").Activate
> > >> > ActiveSheet.protect
> > >> > ActiveSheet.EnableSelection = xlUnlockedCells
> > >> >
> > >> > Mike
> > >> > "Sean" wrote:
> > >> >
> > >> >> 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"
> > >> >>
> > >> >>
> > >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Up down arrow keys do not select cells if select locked cells unch roandrob Microsoft Excel Misc 6 18th May 2009 12:48 AM
Up down arrow keys do not select cells if select locked cells unch roandrob Microsoft Excel Misc 0 17th May 2009 07:18 PM
Macro to select cells without a certain value and select a menu it Guy Microsoft Excel Worksheet Functions 9 2nd Jan 2009 05:21 PM
RE: Select Merged Cells and Unmerge Spread Merge Data To All Cells RyanH Microsoft Excel Programming 0 2nd Oct 2008 03:38 AM
Using formulas to select cells (Ex: Select every nth cell in a col =?Utf-8?B?TGFrZXZpZXcgUGhvdG9ncmFwaGljIFNlcnZpY2Vz Microsoft Excel Misc 2 15th Mar 2007 02:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:18 PM.