Warning Statement to Delete Macro

J

John M

Hello,

I want to create a delete row macro button in a
spreadsheet for several users and want to add a warning
comment such as "Are you sure you want to delete this
row?". I do not know VB very well. Can someone help me
with this code? Thanks.

John
 
P

Paul B

John, how about something like this, assign it to a button on your sheet

Sub test()
Msg = "Are You Sure You Want To Delete Row 2 ?"
Title = "Continue ?"
Response = MsgBox(Msg, vbYesNoCancel + vbQuestion, Title)

If Response = vbNo Then
Exit Sub
End If

If Response = vbCancel Then
Exit Sub
End If
Rows("2:2").Delete Shift:=xlUp

End Sub

--
Paul B
Always backup your data before trying something new
Using Excel 97 & 2000
Please post any response to the newsgroups so others can benefit from it
** remove news from my email address to reply by email **
 

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