Userform + close button

G

Guest

i have a user form and when you click the "Close" button at the bottom it
closes out of the macro/userform it looks like this right now..

Private Sub cmdClose2_Click()
Unload Me
End Sub

what can i add to this sub so that when the button is clicked it

1. saves the workbook
2. closes the worksheet/exit out of excel

thanks!
 
G

Guest

Just add the following to your code:

Unload Me
ActiveWorkbook.Save
Application.Quit
 
H

Harald Staff

Hi Chip

What happens if the user has more than your file open in Excel ? Don't do
that.

Best wishes Harald
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top