Prevent Insert Row and Delete Row from Menu

S

Sherry

I have a list of numbers in rows. I have macros for "Insert Number" and
"Delete Number". These find the correct row and either insert or delete. I
need to control this to protect sums, formulas, etc. Is there a way for me
to prevent the user from inserting or deleting from the Tool Bar?

Thanks for the help!
Sherry
 
S

Sherry

Thank you Jim! I recorded macros to Protect Sheet and checked Insert Row
and Delete Row and one to unprotect. Then I added the macros to my "Insert"
and "Delete" macros. Essentially, I protect when the workbook opens.
Unprotect to insert with macro and then protect back. Same with delete.

The Delete Row macros work great, but when I protect sheet with 'insert row"
selected, I am still able to insert a row by using the Tool Bar. If I delete
a row, I get a message stating that I cannot delete a protected cell (which
is what I want).

I'm using Excel 2003. Do you have an idea why the "insert row" part is not
taking effect?

Sherry
 
G

Gord Dibben

Don't checkmark "Insert Row" when you protect the sheet.

Just code your macro to unprotect, insert the row(s) then reprotect.

Users will only be able to insert rows when hitting your macro button.

Sub InsertRow()
With ActiveSheet
.Unprotect Password:="secret"
With Selection
.EntireRow.Insert
End With
.Protect Password:="secret"
End With
End Sub


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top