简体   繁体   中英

Excel VBA Custom dialog box cancel button code

I have a dialog box pop up with radio buttons, the radio buttons currently run macros. However, once I have the dialog box pop I can't close it. I have added a cancel button. The code is below

Private Sub CommandButton1_Click()
Cmd_Cancel
End Sub

How can I get my dialog box to close by pressing the cancel button?

In my form I used a Cancel button with the below code for it

btnCancel is the (Name) of the button

Private Sub btnCancel_Click()

    Unload Form_Form1

End Sub

Depends on what you want. The keyword "Me" is the actual instance of the Form-Object. Hide it and its still in the memory. Or unload it to kill it: When it's only hidden you can show it again with .show (from another piece of code...)

Private Sub CommandButton1_Click()
    Me.Hide
    Unload Me
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM