yes/no pop up message box

kevinc1973

New Member
Joined
Jun 20, 2019
Messages
15
Hello everyone,
I have a command button that opens up a user form, I would like to add a yes/no message box to the command button and when cell "A4" =01 (01 representing today's date). My message would read"do you want save the data and delete before entering new months data". If yes is selected then it would run my "save macro" and then the "delete macro" and then open up the user form. If no is selected then it would just open the user form. If anyone be able to help would be great thanks.
Kevin
 

Some videos you may like

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Paul Ked

Active Member
Joined
Jun 4, 2015
Messages
442
Code:
Sub OpenForm()
    Dim yn As String
    yn = MsgBox("Do you want to save the data and delete before entering new months data?", , "Save first?")
    If yn = vbYes Then
        SaveMacro
        DeleteMacro
    End If
    frmUser.Show
End Sub
 

Trebor76

Well-known Member
Joined
Jul 23, 2007
Messages
4,609
Here's my attempt:

Code:
Option Explicit
Sub Macro1()

    If Format(Range("A4"), "DD") = "06" Then
        If MsgBox("Do you want save the data and delete before entering new months data?", vbQuestion + vbYesNo) = vbYes Then
            Call SaveMacro
            Call DeleteMacro
            UserForm1.Show
        Else
            UserForm1.Show
        End If
    End If

End Sub
Regards,

Robert
 

kevinc1973

New Member
Joined
Jun 20, 2019
Messages
15
Thank you for code but it didnt seem to work, maybe I put the code in the wrong spot. I opened the code for the command button that opens up the userform and placed it there and it kept going to option explicit in the debugger . I was also wondering once i get this to work, that the pop up message box would not open if sheet "Centrifuge Sheet" cell c4 is empty, because someone already deleted the data. Thanks again for all your help everyone.
Kevin
 

Watch MrExcel Video

Forum statistics

Threads
1,102,552
Messages
5,487,525
Members
407,604
Latest member
sama9000

This Week's Hot Topics

Top