View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
JLatham JLatham is offline
external usenet poster
 
Posts: 3,365
Default protect cells after listbox selection

Ok, that's probably the easiest one to deal with. You can attatch code to
the worksheet's _Change() event to detect when a change in a selection was
made and to figure out if that change took place in the area you are
interested in (where the data validation is used) and then perform actions
when it happens in a cell or cells that are 'of interest' to you.

I just recently uploaded a simple two-sheet workbook to demonstrate another
feature that involves this kind of thing - in this instance the desire was to
have the format of the cell/text where the data validation is used emulate
the format set up in the source list itself. But I think the workbook will
have value in showing you how things have to be set up for you to use the
_Change() event to test for a change in choice and take action based on it.
The workbook can be downloaded from he
http://www.jlathamsite.com/uploads/F...edListDemo.xls

Hopefully that will give you some good ideas. You're going to have to
consider:
possibly unprotecting the sheet before being able to alter the Locked status
of the cells you are going to work with,
performing the actual change in Locked status for the cells
re-protecting the sheet again if appropriate.

You can actually record a macro or two to give you a general idea of the
code needed to perform those operations, although a recorded macro is always
rather strict and literal in choosing sheets/cell ranges/etc and you may need
to make some changes to make the process a little more versatile and robust.


"Chay" wrote:

By the way I used data validation to create a listox. Thanks again and again.

"JLatham" wrote:

Please define 'listbox' - are you referring to a control from one of the
toolbars (the Controls Toolbar or the Forms Toolbar) placed onto a worksheet
or on a user form? Or could you be referring to a list created using Data
Validation in a cell on a worksheet?

Basically you're going to need some code associated with an event triggered
by a change in your listbox to do the work for you.

"Chay" wrote:

How can I protect a range of cells after a listbox selection. Thanks, Chay