UNDO DELEING ROW AND POPUP WARNING MESSAGE

K

K

Hi, I have two macros set on two buttons in my spreadsheet. One macro
add entire row and one macro delete entire row. I want macro in my
Sheet Module that if I cross deleting rows by deleting row macro from
Row 20 in sheet then Message should come up saying that "YOU CANT
DELETE ROWS FROM THIS LINE" and undo the delete row. But below from
Row 20 it should not say anything. Please if anybody help. Thanks
 
M

Mike H

Hi,

A look at your code would have been helpful. Does this help?

Sub stance()
myrow = ActiveCell.Row
If myrow <= 20 Then
MsgBox "You can't delete a row number less than 20"
Else
Rows(myrow).EntireRow.Delete
End If
End Sub

Mike
 
P

Per Jessen

Hi

Try this before the delete statement.

If activecell.row<= 20 then
msgbox ("You cant delete ....")
exit macro
end if

Regards,

Per
 
K

K

Hi

Try this before the delete statement.

If activecell.row<= 20 then
    msgbox ("You cant delete ....")
    exit macro
end if

Regards,

Per

"K" <[email protected]> skrev i meddelelsen



- Show quoted text -

please see the code below the one delete the rows. I have tried
putting macro the one you told me but its not working.
Sub DeleteLines()
Dim StartRow As Long
StartRow = Cells(Rows.Count, 2).End(xlUp).Row
Cells(StartRow, 1).EntireRow.Delete
End Sub
 
M

Mike H

Maybe

Sub DeleteLines()
Dim StartRow As Long
StartRow = Cells(Rows.Count, 2).End(xlUp).Row
If StartRow >= 20 Then
Cells(StartRow, 1).EntireRow.Delete
Else
MsgBox "You can't delete a row under 20"
End If
End Sub

Mike
 
K

K

Maybe

Sub DeleteLines()
Dim StartRow As Long
StartRow = Cells(Rows.Count, 2).End(xlUp).Row
If StartRow >= 20 Then
    Cells(StartRow, 1).EntireRow.Delete
Else
    MsgBox "You can't delete a row under 20"
End If
End Sub

Mike






- Show quoted text -

Thanks Mike that what i want
 

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