ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Referencing UserForm event in module (https://www.excelbanter.com/excel-programming/396766-referencing-userform-event-module.html)

avi

Referencing UserForm event in module
 
Hello,

For the sake of clarity, i want to write event procedures that refer
to some components in a Userform, in a separate regular module. Is it
possible to do so and how should i reference the UserForm in the
regular module?

For example, how should this code look in a regular module, while it
comes from UserForm1?


Sub Label30_Click()
Test_GetAColor
Label30.BackColor = UserColor
End Sub


Many thanks
Avi


Chip Pearson

Referencing UserForm event in module
 
You can't put event procedures in a regular code module. Events can be used
only in an object module (the form's code module, a Sheet module, the
ThisWorkbook module, or a class module).

I don't see what advantage using separate class to handle event would bring,
but you can certainly do it with a class.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"avi" wrote in message
ups.com...
Hello,

For the sake of clarity, i want to write event procedures that refer
to some components in a Userform, in a separate regular module. Is it
possible to do so and how should i reference the UserForm in the
regular module?

For example, how should this code look in a regular module, while it
comes from UserForm1?


Sub Label30_Click()
Test_GetAColor
Label30.BackColor = UserColor
End Sub


Many thanks
Avi



avi

Referencing UserForm event in module
 
Thanks for your clarification.

My need comes from the fact that the Userform code becomes very long
and difficult to manage, but it is not a critical issue

Avi



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

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