I want to protect the sheet and only allow user to delete rows. This possible?

skitzz

New Member
Joined
Jun 8, 2015
Messages
4
I want to protect the sheet and only allow user to delete rows. This possible? I built a user form and i haven't figured out how to create a delete button in the form. So the next best thing os to allow the user to delete that entire row/record. So I need it so that if users create a new record or update a record and want to delete the old one, they can do it in the database tab. Right now when a user creates a record it goes into a table in a separate tab (database table). I don't want the user to be able to delete/add or edit a cell because I have created pre-defined values /dropdowns in the form and they may type in the wrong value.

In the protect worksheet options it says 'Allow all users of this worksheet to:"

Then it lists several functions including "delete rows".

I just cant get it to work. Any thoughts?
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
See if this example is useful:

Code:
' UserForm module
Dim sh As Worksheet

Private Sub CommandButton1_Click()  ' code for delete button
sh.Unprotect "password"
sh.Cells(4, 1).EntireRow.Delete     ' delete a row
sh.Protect "password"
End Sub

Private Sub UserForm_Initialize()
Set sh = Sheets("Sheet1")
If sh.ProtectContents = False Then sh.Protect "password"
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,954
Messages
6,122,462
Members
449,085
Latest member
ExcelError

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