Is it possible to add a parameter in the UserForm_Initialize() function ?

MarieBocc

New Member
Joined
Jun 28, 2019
Messages
33
Hello everyone,

So, yeah, the question is in the title. Can I for instance write something like
Private Sub UserForm_Initialize(rowCount As Integer)
and call it in my macro with
myControl.UserForm_Initialize(rowCount)
and expect it to work ?

Thanks you for reading,

Marie
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
In short no. I don't believe you can.

However you can add public variables to the form and then set them when you create the instance of the form.
 
Upvote 0
Another option would be to send the value to a control on the userform like
Code:
   UserForm1.TextBox1.Value = 123
   UserForm1.Show
or use the Tag property
Code:
   UserForm1.Tag = 123
   UserForm1.Show
 
Upvote 0
If you need the value to be available to the Initialize event, rather than say the Activate event, you'd need to use a public variable (declared in a normal module, not in the userform).
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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