Was wondering if I could get some help on VBA. I've modified some code from the following link:
http://www.mrexcel.com/forum/excel-...unlocking-cells-based-value-another-cell.html
I'd like to unlock/lock column E based on text in column H.
The spreadsheet is protected to start and column E is set to locked. Password is set to "" So if H5 = "","Scheduled","To Do", or "Ongoing" then I'd like for cell E5 to be set to locked and if H5 = "Completed" I'd like for H5 to be set to unlocked. I'd like this to be active so that when a user selects "Completed" in column H the corresponding cell in column E is unlocked and vise versa if selecting something that needs to lock the cell.
Thanks for the help
http://www.mrexcel.com/forum/excel-...unlocking-cells-based-value-another-cell.html
I'd like to unlock/lock column E based on text in column H.
The spreadsheet is protected to start and column E is set to locked. Password is set to "" So if H5 = "","Scheduled","To Do", or "Ongoing" then I'd like for cell E5 to be set to locked and if H5 = "Completed" I'd like for H5 to be set to unlocked. I'd like this to be active so that when a user selects "Completed" in column H the corresponding cell in column E is unlocked and vise versa if selecting something that needs to lock the cell.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("H5:H107")) Is Nothing Then
Dim cell As Range
Unprotect Password:=""
For Each cell In Intersect(Target, Range("H5:H107"))
Select Case cell.Value
Case "", "Scheduled", "To Do", "Ongoing"
cell.Offset(0, -3).Locked = True
Case Else
cell.Offset(0, -3).Locked = False
End Select
Next cell
Protect Password:=""
End If
End Sub
Thanks for the help