ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Closing Userform (https://www.excelbanter.com/excel-programming/395544-closing-userform.html)

Dave M[_2_]

Closing Userform
 
Hello,

I am looking to run a macro whenever the userform is closed, whether by a
cancel button created by me or by clicking the red 'x'.

Thanks

Dave

Jim Rech

Closing Userform
 
That's what the UserForm_QueryClose and UserForm_Terminate event handlers
are for.

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
''Allows cancelling close by setting Cancel = True
End Sub

Private Sub UserForm_Terminate()
''Runs after userform is terminated
End Sub

--
Jim
"Dave M" wrote in message
...
| Hello,
|
| I am looking to run a macro whenever the userform is closed, whether by a
| cancel button created by me or by clicking the red 'x'.
|
| Thanks
|
| Dave




All times are GMT +1. The time now is 12:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com