Referencing UserForm event in module

A

avi

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
 
C

Chip Pearson

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)
 
A

avi

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top