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?
 

Some videos you may like

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Worf

Well-known Member
Joined
Oct 30, 2011
Messages
4,096
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
 

skitzz

New Member
Joined
Jun 8, 2015
Messages
4
Thanks ill try it out. got pulled off of this assignment to work on something else.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,576
Messages
5,596,992
Members
414,115
Latest member
SFUser

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
Top