Dazzybeeguy
Board Regular
- Joined
- Jan 6, 2022
- Messages
- 111
- Office Version
- 365
- 2010
- Platform
- Windows
I have tried using this VBA below to lock cells after an entry in a cell, it works fine but it disables sort & filter, is there any way around this ??
Thanks
Dim mRg As Range
Dim mStr As String
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Range("f3:F1100"), Target) Is Nothing Then
Set mRg = Target.Item(1)
mStr = mRg.Value
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xRg As Range
On Error Resume Next
Set xRg = Intersect(Range("f3:F1100"), Target)
If xRg Is Nothing Then Exit Sub
Target.Worksheet.Unprotect Password:="Password"
If xRg.Value <> mStr Then xRg.Locked = True
Target.Worksheet.Protect Password:="Password"
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Range("f3:F1100"), Target) Is Nothing Then
Set mRg = Target.Item(1)
mStr = mRg.Value
End If
End Sub
Thanks
Dim mRg As Range
Dim mStr As String
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Range("f3:F1100"), Target) Is Nothing Then
Set mRg = Target.Item(1)
mStr = mRg.Value
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xRg As Range
On Error Resume Next
Set xRg = Intersect(Range("f3:F1100"), Target)
If xRg Is Nothing Then Exit Sub
Target.Worksheet.Unprotect Password:="Password"
If xRg.Value <> mStr Then xRg.Locked = True
Target.Worksheet.Protect Password:="Password"
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Range("f3:F1100"), Target) Is Nothing Then
Set mRg = Target.Item(1)
mStr = mRg.Value
End If
End Sub