ExcelBanter

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

Keri

Closing UserForm
 
I am creating a diologue box by creating a UserForm. The UserForm
automatically has a close button (X). I want to be able to change the value
of a cell in the worksheet if that button is pushed. The problem is I can't
seem to find where to write the code, everything I have tried has not worked.


Please Help :)

Toppers

Closing UserForm
 
Keri,
Try this: right click on Userform and "View Code"

Private Sub UserForm_Terminate()
MsgBox "Userform Closed"
' add code to update your cell

End Sub

"Keri" wrote:

I am creating a diologue box by creating a UserForm. The UserForm
automatically has a close button (X). I want to be able to change the value
of a cell in the worksheet if that button is pushed. The problem is I can't
seem to find where to write the code, everything I have tried has not worked.


Please Help :)


Chip Pearson

Closing UserForm
 
Use the QueryClose event of the userform. If the X button was
used to close the form, the CloseMode will be 0. If Unload is
used to dismiss the form, CloseMode will be 1. See help for
QueryClose for more details.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Keri" wrote in message
...
I am creating a diologue box by creating a UserForm. The
UserForm
automatically has a close button (X). I want to be able to
change the value
of a cell in the worksheet if that button is pushed. The
problem is I can't
seem to find where to write the code, everything I have tried
has not worked.


Please Help :)




Keri

Closing UserForm
 
Thanks that worked great :)

"Toppers" wrote:

Keri,
Try this: right click on Userform and "View Code"

Private Sub UserForm_Terminate()
MsgBox "Userform Closed"
' add code to update your cell

End Sub

"Keri" wrote:

I am creating a diologue box by creating a UserForm. The UserForm
automatically has a close button (X). I want to be able to change the value
of a cell in the worksheet if that button is pushed. The problem is I can't
seem to find where to write the code, everything I have tried has not worked.


Please Help :)



All times are GMT +1. The time now is 07:28 AM.

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