PDA

View Full Version : Lock cells and paste values based on a cell value



GregWalter
01-07-2020, 02:17 PM
I'm working with a worksheet and have a working macro that locks cells in a row if a value is present. I'm wondering if I can add an additional step and have it paste values in the row as well before locking them. There are currently active formulas that I want the values locked in once a value is placed in the "N" column.

Below is the current macro I am wishing to add the steps to.


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Sub Data
If Range("N" & Selection.Row).Value <> "" Then
ActiveSheet.Protect Password:="123456", AllowFiltering:=True
ElseIf Range("N" & Selection.Row).Value = "" Then
ActiveSheet.Unprotect Password:="123456"
ActiveSheet.EnableSelection = x1NoRestrictions
End If
End Sub

Any help you can give is greatly appreciated!