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
 

Paul Ked

Active Member
Joined
Jun 4, 2015
Messages
441
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,437
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
 

Forum statistics

Threads
1,078,353
Messages
5,339,720
Members
399,320
Latest member
sut3k

Some videos you may like

This Week's Hot Topics

Top