asthmatic_weasel
New Member
- Joined
- Nov 18, 2022
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
Good afternoon all,
I have a excel sheet that is an output from a powershell script. We will to run the powershell script again and want to make sure that certain rows are not overwritten. I am ok at VBA but not amazing by any standard and have tried to place the following code.
Private Sub Worksheet_Calculate()
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
Me.Unprotect
For i = 1 To LR
With Range("N" & i)
If .Value = "TRUE" Then .EntireRow.Locked = True
End With
Next i
Me.Protect
End Sub
However it still allows me to edit cells that should be locked. Does anyone think this would work? Am I close to getting it to work or am I completely wrong? Have I missed a step somewhere maybe?
Just for honesty and integrity that code above was found on the internet and I copied and adjusted as I saw suitable.
Any help or pointers would be great
I have a excel sheet that is an output from a powershell script. We will to run the powershell script again and want to make sure that certain rows are not overwritten. I am ok at VBA but not amazing by any standard and have tried to place the following code.
Private Sub Worksheet_Calculate()
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
Me.Unprotect
For i = 1 To LR
With Range("N" & i)
If .Value = "TRUE" Then .EntireRow.Locked = True
End With
Next i
Me.Protect
End Sub
However it still allows me to edit cells that should be locked. Does anyone think this would work? Am I close to getting it to work or am I completely wrong? Have I missed a step somewhere maybe?
Just for honesty and integrity that code above was found on the internet and I copied and adjusted as I saw suitable.
Any help or pointers would be great