yes/no pop up message box

kevinc1973

New Member
Joined
Jun 20, 2019
Messages
22
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
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
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
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,223,701
Messages
6,173,920
Members
452,539
Latest member
deeme

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top