ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Multiple Userform Macro Headache (https://www.excelbanter.com/excel-programming/368649-multiple-userform-macro-headache.html)

[email protected]

Multiple Userform Macro Headache
 
Hello all,

This is my first time posting to this group, so I'm sorry if I
(unintentionally) don't follow proper conventions.

My problem is with creating a macro that utilizes multiple userforms.
Of course, this means that each userform has its own name, own code,
etc. The problem lies with the Userform_Initialize() event. If I use
this code:

PartsFindForm.Show 'where PartsFindForm is the name of the userform

Userform_Initialize() gives me an error and Excel refuses to run until
I change the name to PartsFindForm_Initialize(). Of course, Excel then
no longer recognizes this as an event and skips any code inside the
Sub. What should I do to make this work? As of now I am running
everything with the Userform_Activate() event which works perfectly
(like Initialize() should) with the problem that code that I only want
running once gets run multiple times. This error also occurs with Load,
Hide, and any other Userform specific commands.

Any help would be greatly appreciated! Thank you.

-Larry


Tom Ogilvy

Multiple Userform Macro Headache
 
renaming initialize just causes it not to fire, so there is nothing magic
there.

It sounds like you have a duplicate name defined somewhere. Maybe you named
a variable userform or named a procedure Userform.

You may need to find this problem and change it, then rebuild your project
use Rob Bovey's free code cleaner utility
http://www.appspro.com - goto downloads

--
Regards,
Tom Ogilvy


" wrote:

Hello all,

This is my first time posting to this group, so I'm sorry if I
(unintentionally) don't follow proper conventions.

My problem is with creating a macro that utilizes multiple userforms.
Of course, this means that each userform has its own name, own code,
etc. The problem lies with the Userform_Initialize() event. If I use
this code:

PartsFindForm.Show 'where PartsFindForm is the name of the userform

Userform_Initialize() gives me an error and Excel refuses to run until
I change the name to PartsFindForm_Initialize(). Of course, Excel then
no longer recognizes this as an event and skips any code inside the
Sub. What should I do to make this work? As of now I am running
everything with the Userform_Activate() event which works perfectly
(like Initialize() should) with the problem that code that I only want
running once gets run multiple times. This error also occurs with Load,
Hide, and any other Userform specific commands.

Any help would be greatly appreciated! Thank you.

-Larry




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

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