View Single Post
  #2  
Old January 9th, 2004, 05:54 PM
Dave Smith
external usenet poster
 
Posts: n/a
Default Locking other cells based on values in a cell

This function will lock or unlock cells in columns B-D when the value in A
is changed:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rColAChanged As Range
Dim cCell As Range

If Not Intersect(Target, Range("A:A")) Is Nothing Then
ActiveSheet.Unprotect
Set rColAChanged = Intersect(Target, Range("A:A"))
For Each cCell In rColAChanged
cCell.Offset(0, 1).Resize(1, 3).Locked = (cCell.Value
"Plumb")
Next
ActiveSheet.Protect
End If
End Sub

It would be nice if this sort of thing could be done as a conditional
format. Anyone have a better way to do this?

Dave

wrote in message
...


| A| B| C| D|
------------------------------------------
1|Task |Desc |Hrs |Date |
2|Stucco |
3|Paint |
4|Plumb |

Lets say above is my sample spread sheet. How can I
block/lock the cells for col B, Col C and Col D in a row
if the value in Col A of same row is not "Plumb".

In other words if A2 is not equal to "Plumb" then cells
B2, C2 and D2 has to be locked and made not editable or
non-data-enterable.


Please help

Thanks

Thanks
Mario