imback2nite
Board Regular
- Joined
- Oct 30, 2004
- Messages
- 203
- Office Version
- 2003 or older
- Platform
- Windows
Thank you for looking. I'm having problems with to top part of this code. What I want is for the user to be unable to delete rows 1 through 10. Sometimes this code will work, sometimes not. What am I doing wrong?
VBA Code:
Private Sub CommandButton1_Click()
If ActiveCell.Rows >= 10 Then
MsgBox "You cannot insert a new line here"
Exit Sub
Else
End If
ActiveSheet.Unprotect
Dim answer As Integer 'Delete Lines
answer = MsgBox("Have You Selected The Row(s) To Delete?", vbQuestion + vbYesNo + vbDefaultButton2, "Delete Row")
If answer = vbYes Then
Selection.EntireRow.Delete
Else
If answer = vbNo Then
MsgBox "Please Select Row To Delete.", , "Delete Row"
End If
End If
Application.ScreenUpdating = False
lr = Cells.Find("*", Cells(1, 1), xlFormulas, xlPart, xlByRows, xlPrevious, False).Row
Range("K9").Formula = "=IF($K8="""","""",IF(AND($H9="""",$J9=""""),"""",$K8+$J9-$H9))"
Range("K9").AutoFill Range("K9:K" & lr)
End Sub