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.
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
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:
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.
Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!
Need to protect the data in your workbook so that others can't get at it? Here are some ideas on how you can approach the ...
Discover MoreExcel allows you to apply protection to your workbooks. If you want to later change the passwords associated with that ...
Discover MoreIf you want to protect your workbook so that others cannot open or change the information it contains, an easy way to ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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.
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments