Load an Userform

Manuel Cavero

New Member
Joined
Feb 17, 2018
Messages
26
Good morning everyone:

I have to develop a piece of code that calls an useform form two different places. The first one piece of code needs to load an UserForm in memory, so what I doing now if load the UserForm calling forma normal module this way:
Code:
UFPAR.PPRUE

Where UFPAR is the UserForm and PPRUE is a Public Sub that loads values in a Dictionary.

From another module I'm calling the Userform with this piece of code:

Code:
Private Sub CBPares_click()
UFPAR.PPRUE
UFPAR.Show vbModeless
End Sub

I've a problem with the first item, sometines works right and sometimes VBA gives me an error, telling that the object (UFPAR or the UserForm) is Null, because the first piece of code doesn't load the UserForm.

Trying to change the way of doing the load of the userform, I tryed to used

Code:
LOAD UFPAR
or
Code:
LOAD (UFPAR)

But VBE doesn't loads the UserForm. Why?
 
Manuel,

I mocked up a workbook with the portions of your code that you provided, and the userform opened and populated the listbox without raising the error. I repeated the call several times from the button sub, and from a procedure in a worksheet module (which is what you appeared to be doing when the error arose as shown in your image).

I suspect the problem is related to your calling the Userform's PPRUE sub, without having first created an instance of the Userform from a Standard Code Module.

I'd suggest you create an instance of the Userform from a Standard Code Module, then populate the listbox instead of trying to do those within the same call.
 
Last edited:
Upvote 0

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

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