![]() |
Conditional Cell Protection
In Excel, is there anyway to protect a cell only if it meets a certain
condition? |
This can be achieved through a macro, however, you would need to store the
password in the macro to unlock the sheet in order to make the changes - assuming you have locked the sheet. You would need to write the code in the VBA object for the sheet in question, then using the macro: Private Sub Worksheet_Change(ByVal Target As Range) 'find if condition is met for the cells in question then lock the cell ' assuming the cells in question are in B1:B5 Activesheet.Unprotect Password:="myPassword" With ActiveSheet.Range("B1:B5") For i = 1 to .Rows.Count If .Cells(i, 1).Value 10 Then .Locked = True End If Next I End With Activesheet.Protect Password:="myPassword" End Sub "Gyges" wrote: In Excel, is there anyway to protect a cell only if it meets a certain condition? |
All times are GMT +1. The time now is 06:56 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com