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

chrisgarcia78

New Member
Joined
Jun 15, 2024
Messages
31
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

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
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,223,880
Messages
6,175,153
Members
452,615
Latest member
bogeys2birdies

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