![]() |
Lock cell if based on value of corresponding cell
Hi, I was tring to lock cell if value of corresponding cell is error
If value B3:B20 is error lock corresponding cells in ColumnE, F & H OR unlock cell if value of corresponding cell is 0 If value B3:B20 is 0 unlock corresponding cells in ColumnE, F & H |
Lock cell if based on value of corresponding cell
Putting this module into the individula sheet in the VBA editor will lock or
unlock the cells everytime the sheet is changed. Sub Worksheet_Change(ByVal target As Range) ActiveSheet.Unprotect For B = 3 To 20 If IsError(Cells(B, 2)) Then Cells(B, 5).Locked = True Cells(B, 6).Locked = True Cells(B, 8).Locked = True Else If Cells(B, 2) 0 Then Cells(B, 5).Locked = False Cells(B, 6).Locked = False Cells(B, 5).Locked = False End If End If Next B ActiveSheet.Protect End Sub or you could tie this same routine to a button if you only want to run it on demand. -- If this helps, please remember to click yes. "Kashyap" wrote: Hi, I was tring to lock cell if value of corresponding cell is error If value B3:B20 is error lock corresponding cells in ColumnE, F & H OR unlock cell if value of corresponding cell is 0 If value B3:B20 is 0 unlock corresponding cells in ColumnE, F & H |
All times are GMT +1. The time now is 09:58 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com