'How to close a `Userform` after clicking a button
I have a Corel Draw issue using Exit Sub to close a Userform after clicking a button.
It will run the script to completion, but won't execute the Exit Sub command.
I tried setting a dummy variable to a true value If X=1 then Exit Sub but that didn't do the trick either.
Private Sub CommandButton1_Click()
MsgBox "Script Ran!"
Exit Sub
End Sub
My hope is to click a button, and have the userform close after it runs. My impression was Exit Sub is the way to do this.
Solution 1:[1]
Exit Sub functions as an exit point of the current Sub.
Having it before End Sub does literally nothing except leaving the Sub one line earlier.
What you want is Unload Me.
See the relevant VBA documentation of the Unload Statement.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nacorid |

