Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Limiting Who Can Delete Data.

Limiting Who Can Delete Data

Written by Allen Wyatt (last updated August 3, 2024)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


1

Jim has a workbook that is used by multiple people in his company. He wonders if there is a way to allow everyone to add data to a group of cells, yet restrict who can delete the data from the cells. He has a group of about 50 that he wants to be able to add data, but he wants to give the delete capability to just 2 individuals.

There are any number of macro-based solutions you can try. Essentially, you need a macro to detect when information has been deleted and then check to see if the person deleting the information has permission to do so. The following is just one possible approach to the issue:

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim sPassCheck As String
    Dim sTemp As String
    Dim sPassword As String

    sPassword = "Password"
    sTemp = "You must enter the password to delete data"

    If Target.Cells(1, 1).Value = "" Then
        sPassCheck = InputBox(sTemp, "Delete check!")
        Application.EnableEvents = False
        If sPassCheck <> sPassword Then Application.Undo
    End If

    Application.EnableEvents = True
End Sub

The macro, which is actually an event handler triggered whenever something in the worksheet is changed, checks to see if the information in the top-left corner of the range was deleted. If so, then the user is asked for a password. If the person doesn't have the password, then the Undo method is invoked to "undo" the person's deletion. (You'll want to change the password, assigned to the sPassword variable) to the actual password you want people to use.)

As I said, this macro is just one possible approach. You'll want to think through how your worksheet may be used and then craft a macro to reflect that usage. For instance, you might want to check the Application.UserName property and, if it isn't a specific user, disallow the changes.

Another option is to use an Excel add-in that can take care of the security issues for you. Some subscribers suggest using Add-In A-Tools. You can find more information about this add-in here:

https://www.atoolspro.com/

Add-In A-Tools, among other things, apparently allows you to apply various security features to Excel data that resides on a network. (Chances are good that Jim is sharing his workbook on a network, as it is used by many people in his company.)

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11598) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Excel here: Limiting Who Can Delete Data.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Working with E-mailed Documents

Ding! You've got mail. That mail has a Word document attached to it. Before you rush off and open that document, take a ...

Discover More

Determining the Size of a File

When processing a document using a macro, you may need to know the precise size of a particular file. The way you figure ...

Discover More

Determining if a Document is Corrupt

Think you might have a corrupt document? There is no easy way to tell if this is the case, but there are some things you ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Locking Worksheet Tab Order

When you develop a workbook for others to use, you may want to make sure that those users cannot change the order in ...

Discover More

Protecting an Entire Folder of Workbooks

Want to protect the Excel information stored in a particular folder on your system? There are a number of ways you can ...

Discover More

Saving a Workbook Using Passwords

If you want to protect your workbook so that others cannot open or change the information it contains, an easy way to ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 2 + 5?

2024-08-03 08:56:12

Chris Lefsrud

hmmm...
As I recall, I have segmented privileges as described in this inquiry, by using the 'Allow Users to Edit Ranges' option on the 'Review' menu. I am now retired and no longer have access to a network environment where I could test and verify.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.