+ Reply to Thread
Results 1 to 6 of 6

pop up before

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-21-2007
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    389

    pop up before

    Hello,

    I am using the below macro to delete rows. Would you know how I can insert a message before running the macro such as "are you sure you'd like to delete the row?"

    Sub REMOVE()
        rw = ActiveCell.Row
        If rw >= 12 And rw <= 28 Then
        Else
            ActiveSheet.Unprotect Password:="p@ssw0rd!"
            Set rng = ActiveCell
            ActiveCell.EntireRow.Delete
            ActiveSheet.Protect Password:="p@ssw0rd!", AllowFormattingCells:=True
        End If
    End Sub
    Many Thanks,
    Graig

  2. #2
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: pop up before

    Sub Remove()
    
    MsgBox "Are you sure?", vbYesNo
    If vbNo Then Exit Sub
        rw = ActiveCell.Row
        If rw >= 12 And rw <= 28 Then
        Else
            ActiveSheet.Unprotect Password:="p@ssw0rd!"
            Set Rng = ActiveCell
            ActiveCell.EntireRow.Delete
            ActiveSheet.Protect Password:="p@ssw0rd!", AllowFormattingCells:=True
        End If
    
    
    
    Exit Sub
    
    
    End Sub
    You should hit F5, because chances are I've edited this post at least 5 times.
    Example of Array Formulas
    Quote Originally Posted by Jacc View Post
    Sorry, your description makes no sense. I just made some formula that looks interesting cause I had nothing else to do.
    Click the * below on any post that helped you.

  3. #3
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: pop up before

    Try

    Sub REMOVE()
    Dim vbConfirm
    vbConfirm = MsgBox("ARE YOU SURE?", vbQuestion + vbYesNo, "Fotis1991")
    If Not vbConfirm = vbYes Then Exit Sub
        rw = ActiveCell.Row
        If rw >= 12 And rw <= 28 Then
        Else
            ActiveSheet.Unprotect Password:="123"
            Set Rng = ActiveCell
            ActiveCell.EntireRow.Delete
            ActiveSheet.Protect Password:="123", AllowFormattingCells:=True
        End If
    End Sub
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  4. #4
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: pop up before

    That's what i get for no testing.


    Amendment to my original response;

    Dim a
    a = MsgBox("Are you sure?", vbYesNo)
    If a = vbno Then Exit Sub

  5. #5
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: pop up before

    add
    If MsgBox("Are you sure?", vbYesNo) = vbNo Then Exit Sub
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  6. #6
    Forum Contributor
    Join Date
    02-21-2007
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    389

    Re: pop up before

    Following the reply by order, I tried out Fortis Macro and works perfectly.

    Many Thanks Guys!!
    Graig

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1