ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UserForm_Initialize (https://www.excelbanter.com/excel-programming/288004-userform_initialize.html)

Rob

UserForm_Initialize
 
I've got my UserForm_Initialize event to empty all the
form fields, but sometimes values appear when the form is
loaded. Am I using the wrong event?

Chip Pearson

UserForm_Initialize
 
Rob,

The Initialize event is executed when the form is loaded in to
memory, not when it is displayed. Therefore, if you load (or
show for the first time) the form, Initialize will run. If you
then Hide the form and Show it again without Unloading the form,
Initialize will not run. If you need to run Initialize every time
the form is shown, you should Unload the form after hiding it.


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

"Rob" wrote in message
...
I've got my UserForm_Initialize event to empty all the
form fields, but sometimes values appear when the form is
loaded. Am I using the wrong event?




DennisE

UserForm_Initialize
 
Rob,

have you checked what's happening in the UserForm_Activate event? Bringing up
the form using UserForm.Show triggers both
the Initialize and Activate events.

-- Dennis Eisen


All times are GMT +1. The time now is 08:49 AM.

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