PDA

View Full Version : Lock Row on Cell input.



Shazam
03-14-2012, 08:15 AM
Hi Everyone,

If a user input a text or number in Cell G2 then the entire row from A2:F2 gets locked. Then if the user input a text or number in cell G3 then the entire row from A3:F3 gets locked.

Column G is where users going to input data.

Also, can I have a password protection?

Is there a code for this?

Thanks!

Kenneth Hobs
03-14-2012, 11:11 AM
Right click the sheet's tab, View Code, and paste:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 7 Then Exit Sub
ActiveSheet.Protect "ken", UserInterfaceONly:=True
If IsEmpty(Target) Then
Range("A" & Target.Row, "F" & Target.Row).Locked = False
Else
Range("A" & Target.Row, "F" & Target.Row).Locked = True
End If
End Sub

Your Column G should be unprotected. Change password ken to yours.

Shazam
03-14-2012, 11:49 AM
Thanks!

It's perfect.