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" <Keri@discussions.microsoft.com> wrote in message
news:6D1FD850-6E89-4E38-B5D4-6FE417A772C9@microsoft.com...
>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