Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Locking other cells based on values in a cell.



| 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.

Thanks
Mario
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Locking other cells based on values in a cell.

Mario,
This checks the two cells specified in the first IF statement only
You will want to format all cells that you wish to reamain unlocked as the ActiveSheet.Protect affects the entire sheet. The default for a cell is to be locked if the sheet if protected, hence all cells will be protected unless you change the formatting.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$4" Or Target.Address = "$A$5" Then
If Target = "Plumb" Then
ActiveSheet.Unprotect
Target.Offset(0, 1).Cells.Locked = True
Target.Offset(0, 2).Cells.Locked = True
Target.Offset(0, 3).Cells.Locked = True
ActiveSheet.Protect
Else
ActiveSheet.Unprotect
Target.Offset(0, 1).Cells.Locked = False
Target.Offset(0, 2).Cells.Locked = False
Target.Offset(0, 3).Cells.Locked = False
ActiveSheet.Protect
End If
End If
End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Locking a cell based on a cells content The Rook[_2_] Excel Discussion (Misc queries) 1 June 2nd 10 08:41 PM
Excel Locking cells based on value in another cell Kelson Excel Discussion (Misc queries) 2 October 10th 07 10:49 PM
locking cells based on results at runtime aken Excel Worksheet Functions 3 June 22nd 05 02:01 PM
Modify Row & Cell Contents based upon Cells Values bpat1434 Excel Worksheet Functions 0 November 7th 04 03:31 PM
Modify Row & Cell Contents based upon Cells Values bpat1434 Excel Worksheet Functions 1 November 7th 04 03:12 AM


All times are GMT +1. The time now is 05:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"