AW: Delete Rows
24.01.2011 15:01:23
Gerald
oder so?
Sub Workbook_Open()
Application.OnKey "{DELETE}", "ThisWorkbook.DelSelectedRow"
End Sub
Sub DelSelectedRow()
Static row_to_delete As Integer
row_to_delete = Selection.Row
For i = 1 To Sheets.Count
If ActiveSheet.Name "Template"
'If Selection.Parent.Name = .Name Then
'check to make sure a row is selected
If Selection.Rows.Count = 1 And Selection.Cells.Count = 16384 Then
ActiveSheet.Unprotect Password:="Secret"
ActiveSheet.Rows(row_to_delete).Delete
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowInsertingColumns:=True, _
AllowInsertingRows _
:=True, AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, _
_
AllowDeletingRows:=True, AllowSorting:=True, AllowFiltering:=True, _
_
AllowUsingPivotTables:=True, Password:="Secret"
Exit For
End If
'End If
End If
Next i
End Sub