ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   protect cells after listbox selection (https://www.excelbanter.com/excel-discussion-misc-queries/120671-protect-cells-after-listbox-selection.html)

Chay

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

JLatham

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


JLatham

protect cells after listbox selection
 
Also, Gord Dibben has given some good code example for the process in a post
in the other discussion with this same topic put up by you.

"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


Chay

protect cells after listbox selection
 
Thank you very much, JLathan. You a genius!!!!!

"JLatham" wrote:

Also, Gord Dibben has given some good code example for the process in a post
in the other discussion with this same topic put up by you.

"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



All times are GMT +1. The time now is 11:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com