jacoblewis1994
New Member
- Joined
- Dec 15, 2015
- Messages
- 4
Hi,
I have a Yes / No data validation list in column A. When Yes is selected I want rows B - T to be locked and want it unlocked when it is empty / no is selected.
The below code works brilliant but only when one cell is inputted with Yes. When multiple cells in column A are inserted with Yes (e.g. copy and paste) then the Type 13 Mismatch error comes up.
When I hit debug the following bit of code is highlighted:
Any help would be appreciated.
Thanks
I have a Yes / No data validation list in column A. When Yes is selected I want rows B - T to be locked and want it unlocked when it is empty / no is selected.
The below code works brilliant but only when one cell is inputted with Yes. When multiple cells in column A are inserted with Yes (e.g. copy and paste) then the Type 13 Mismatch error comes up.
Code:
Private Sub WorkSheet_Change(ByVal Target As Range)
If Target.Column > 1 Then Exit Sub
ActiveSheet.Unprotect
Select Case Target.Value
Case "Yes"
With Target.EntireRow
.Locked = True
.FormulaHidden = True
End With
Case Else:
With Target.EntireRow
.Locked = False
.FormulaHidden = False
End With
End Select
With Target.EntireColumn
.Locked = False
.FormulaHidden = False
End With
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub
When I hit debug the following bit of code is highlighted:
Code:
Case "Yes"
Any help would be appreciated.
Thanks