Protecting a Cell but allowing data validation drop down list to work

chrisgarcia78

New Member
Joined
Jun 15, 2024
Messages
24
Office Version
  1. 2021
Platform
  1. Windows
Hi, I have a cell that's proteced because it has a formula that I want to prevent it from being deleted, the same cell has a drop down list which does not work because the cell is locked, I understand that the formula will be deleted anyway after I select an option from the drop down list but thats ok, I just want to prevent it from being deleted accidentally before selecting an option from the drop down list. How do I make this work?
Thank you in advance.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Let's assume that the cell in question is B2.
Requirements:
1. The cell is not locked.
2. When defining the validation list, the checkbox “Ignore blank” must NOT be checked.
3. After the above steps, the worksheet is protected.

Paste the following event procedure into the sheet module:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Address = "$B$2" Then
        If Not Target.Validation.Value Then
            Application.EnableEvents = False
            Application.Undo
            Application.EnableEvents = True
        End If
    End If

End Sub
If the user pastes a value other than the one allowed by the validation list into cell B2, the action will be undone without warning. If the user types a value outside the list, he will receive a validation message.

Artik
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top