Userforms: load, unload, show, hide

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,834
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Would I be correct in saying that:

Code:
Userform.Show

automatically loads it (and displays it on the screen), whereas:

Code:
Unload Userform

will deactivate the userform (and therefore remove it from the screen)?

If I am correct, does it mean there's little use in:

Code:
Load Userform

and

Userform.Hide

Thanks
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
when a userform is unloaded, the variables are removed from memory and the form must be loaded or shown to reinitialise the variables and display the form. on the other hand a form can be hidden and shown without destruction of the variables (and hence their values)
a userform is also loaded if you assign a value to a control on the form from a subroutine not part of the form code. so you might assign the next invoice number to the form prior to it being shown from a main module and then show it to fill in the details
 
Upvote 0
Solution
when a userform is unloaded, the variables are removed from memory and the form must be loaded or shown to reinitialise the variables and display the form. on the other hand a form can be hidden and shown without destruction of the variables (and hence their values)
a userform is also loaded if you assign a value to a control on the form from a subroutine not part of the form code. so you might assign the next invoice number to the form prior to it being shown from a main module and then show it to fill in the details
Thanks for your explanation.
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,626
Members
449,094
Latest member
bsb1122

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