HiIamMason
New Member
- Joined
- Dec 18, 2019
- Messages
- 4
- Office Version
- 365
- Platform
- Windows
Hello Friends,
I am new to VBA and i have trying to set a code up that does the following.
If values are entered in any given row of column F. all the columns in that given row will be locked and protected.
I know it does not look pretty, hope somebody is able to help me.
I am new to VBA and i have trying to set a code up that does the following.
If values are entered in any given row of column F. all the columns in that given row will be locked and protected.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Set Rng = Range("F2:F999999")
If Sheets("Sheet1").ProtectContents = True Then Sheets("Sheet1").Unprotect Password:="myPass"
For Each cell In Rng
If WorksheetFunction.CountA(Range("rng")) = 0 Then
Else
If Sheets("Sheet1").ProtectContents = True Then Sheets("Sheet1").Unprotect Password:="myPass"
Range("A2:E6").Locked = True
End If
Sheets("Sheet1").Protect Password:="myPass", UserInterfaceOnly:=True
End Sub
I know it does not look pretty, hope somebody is able to help me.
Last edited by a moderator: