Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
lock a cell based on cell value
I am running Excel 2003 with a spreadsheet that has Activity in column A,
Status (Open or Closed) in column B, Days of Week (Sun thru Sat) in columns C thru I. I am looking for a way to "lock" columns C thru I if column B is "Closed" for each row of Activity in Column A example: Col A Col B Col C Col D Col E Col F Activity 1 Closed lock lock lock lock Activity 2 Open unlock unlock unlock unlock |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
lock a cell based on cell value
Assume that we begin with the worksheet unprotected and all cells unlocked.
Install this event macro in the worksheet code area: Private Sub Worksheet_Change(ByVal Target As Range) Dim t As Range Dim b As Range Dim trow As Long Set t = Target Set b = Range("B:B") If Intersect(t, b) Is Nothing Then Exit Sub If t.Value < "Closed" Then Exit Sub trow = t.Row ActiveSheet.Unprotect Range("C" & trow & ":I" & trow).Locked = True ActiveSheet.Protect End Sub Because it is worksheet code, it is very easy to install and automatic to use: 1. right-click the tab name near the bottom of the Excel window 2. select View Code - this brings up a VBE window 3. paste the stuff in and close the VBE window If you have any concerns, first try it on a trial worksheet. If you save the workbook, the macro will be saved with it. To remove the macro: 1. bring up the VBE windows as above 2. clear the code out 3. close the VBE window To learn more about macros in general, see: http://www.mvps.org/dmcritchie/excel/getstarted.htm To learn more about Event Macros (worksheet code), see: http://www.mvps.org/dmcritchie/excel/event.htm -- Gary''s Student - gsnu200821 "Texins Karate" wrote: I am running Excel 2003 with a spreadsheet that has Activity in column A, Status (Open or Closed) in column B, Days of Week (Sun thru Sat) in columns C thru I. I am looking for a way to "lock" columns C thru I if column B is "Closed" for each row of Activity in Column A example: Col A Col B Col C Col D Col E Col F Activity 1 Closed lock lock lock lock Activity 2 Open unlock unlock unlock unlock |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
lock cell based on a condition | Excel Worksheet Functions | |||
I have lock a wookbook but one cell does not want to lock it | Excel Discussion (Misc queries) | |||
I have lock a wookbook but one cell does not want to lock it | Excel Discussion (Misc queries) | |||
Lock data in a cell a specific cell based on selection on other ce | Excel Worksheet Functions | |||
How to lock a row in a spreadsheet based on the value in a cell | Excel Worksheet Functions |