Can you lock certain cells so the reps using the Excel can't change? Basically they are continually overriding the formulas in place cause errors, can I lock the cells that have formulas?
Can you lock certain cells so the reps using the Excel can't change? Basically they are continually overriding the formulas in place cause errors, can I lock the cells that have formulas?
.
When you lock a cell or individual cells you also have to protect the entire worksheet for it to take effect. That makes the entire sheet inaccessible.
Here is a workaround however. It "watches" a set range and if the user attempts to enter anything into those cells, the cursor is directed to a different
area of the sheet. A message box warning can be added to advise the user their actions are unwarranted.
![]()
Please Login or Register to view this content.
Thanks for this, is this VBA code? Reason I ask is I already have a code in place for a different reason am I able to apply two different codes in the same worksheet? I'm no pro with coding, if you can do two how would I achieve that? This is the current code allowing to have multiple selections in a drop down, how do I add to it?
Private Sub Worksheet_Change(ByVal Target As Range)
'Updated by AprilBenjamin-Martins 2019/11/13
Dim xRng As Range
Dim xValue1 As String
Dim xValue2 As String
If Target.Count > 1 Then Exit Sub
On Error Resume Next
Set xRng = Cells.SpecialCells(xlCellTypeAllValidation)
If xRng Is Nothing Then Exit Sub
Application.EnableEvents = False
If Not Application.Intersect(Target, xRng) Is Nothing Then
xValue2 = Target.Value
Application.Undo
xValue1 = Target.Value
Target.Value = xValue2
If xValue1 <> "" Then
If xValue2 <> "" Then
If xValue1 = xValue2 Or _
InStr(1, xValue1, ", " & xValue2) Or _
InStr(1, xValue1, xValue2 & ",") Then
Target.Value = xValue1
Else
Target.Value = xValue1 & ", " & xValue2
End If
End If
End If
End If
Application.EnableEvents = True
End Sub
.
Yes you can.
Your macro is using the Worksheet_Change event.
My macro is using the Worksheet_SelectionChange.
Two different animals.
Give it a try and see what happens. If you have any concerns, make a copy of your workbook and try it there first.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks