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,435
Messages
5,340,250
Members
399,361
Latest member
Linford

Some videos you may like

This Week's Hot Topics

  • Problem with Radio Button's format control
    I am creating an employee evaluation template (a sample is below) Column A is the category Column B, C D, E and F will be ratings (unacceptable...
  • Last Display on userform to a Listbox
    [CODE=vba] lstdisplay.ColumnCount = 15 lstdisplay.RowSource = "A1:O600000" [/CODE] So when i do this it Displays everything on the sheet i am...
  • Rename and move files to a new location
    Dear all, I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following...
  • Help with True/False Formula
    Hello! Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True...
  • Clear extra characters from a provided range of cells
    Dear All, I have following code which gives me desired output to remove extra characters from a provided range. But it takes too much time when...
  • Help with Current and highest streaks
    Hi there, I've just joined the forum and this is my first post. I've already spent quite a bit of time searching the net and this forum for a...
Top