View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
Tom Hutchins Tom Hutchins is offline
external usenet poster
 
Posts: 1,069
Default Allow user to delete cell ranges?

I suggest you add a command button to the sheet with a caption like "Delete
selected cells'. Set the Locked property of this button to False (so it
doesn't get locked when you protect the sheet). In the click event for the
button, use VBA to unprotect the sheet, delete the selected cell(s), and
reprotect the sheet. For example,

Private Sub CommandButton1_Click()
Dim C As Range
ActiveSheet.Unprotect Password:="aaa"
For Each C In Selection
If C.Locked = False Then
C.Delete Shift:=xlUp
End If
Next C
ActiveSheet.Protect Password:="aaa", _
DrawingObjects:=True, Contents:=True
End Sub

This code looks at each cell selected be the user. If that cell is locked,
it is not deleted. Selected cells that are not locked are deleted and the
cells below shift upward.

Hope this helps,

Hutch

"Dave Mathew" wrote:

I just tried unlocking a row and it will allow me to delete the entire
row but what I am wanting to do is select and delete a specific range
of cells in a row, which it appears still isn't allowed even if I
unlock the entire row... i.e. I can only delete a row by right
clicking on the row header on the left and selecting delete, when I
select a few cells in the row and right click on the selection the
delete option is still grayed out.