Run VBA prior to form closing

EssKayKay

Active Member
Joined
Jan 5, 2003
Messages
437
Office Version
  1. 2007
Platform
  1. Windows
Is there a way to run a macro prior to closing a user form -- by clicking the standard "X" (close) button in the upper right corner not via a separate command button?
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
I may have found another routine that appears to be working - Private Sub UserForm_Terminate().
However, maybe there is some reason to shy away from this.

Any suggestions?
 
Upvote 0
I may have found another routine that appears to be working - Private Sub UserForm_Terminate().
However, maybe there is some reason to shy away from this.

Explanation for use of Terminate event in your project can be found in the VBA helpfile.
I suspect the QueryClose event likely to more appropriate for your requirement.

Dave
 
Upvote 0

Forum statistics

Threads
1,225,635
Messages
6,186,120
Members
453,340
Latest member
Stu61

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top