VBA Code Help

gnaga

Well-known Member
Joined
Jul 9, 2002
Messages
748
Office Version
  1. 365
  2. 2016
  3. 2013
Platform
  1. Windows
Hi,

I am writing a macro involves a user form. I am adding the controls like command button,textbox in run time. Now my problem is how to write the procedure for the events of that added controls.

I know how to write event procedure for the control's added in design time.

Thanks

GNaga
 
I have programmatically created arrays of controls, in my case, the controls was assigned as listboxes.

But, you won't get events for them. Sorry.

In my case, all the listboxes were to share the same location on the form, and only one was going to be .visible at any moment.

So, in order to have events, I set up a "proxy" control; that control shares the various property assignments of the invisible array element. The proxy control events updates the hidden control. It works well.

In your case, it doesn't seem that having a proxy will do you much good.
 
Upvote 0

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Thanks Steave. It looks very hard to do. As Andrew suggested I may have to add controls in design time. Thanks for all you guys.

GNaga
 
Upvote 0
In the VBIDE the CodeModule Object has a CreateEventProc Method, which purports to create an event procedure. I say purports because Excel crashed when I tried to use it.
 
Upvote 0

Forum statistics

Threads
1,225,055
Messages
6,182,594
Members
453,126
Latest member
NigelExcel

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