Refreshing userforms

Helper monkey

Board Regular
Joined
Jun 23, 2002
Messages
63
Hi,

Is it possible to 'refresh' a userform or is the best option to unload and reload?

I have comboboxes and text boxes that i would like to be refreshed once used - i.e. once a commandbutton is clicked.

Thanks
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

dmckinney

Board Regular
Joined
Jul 10, 2002
Messages
120
The short answer is that it's best to refresh the userform rather than try to reload it.

I guess you've got form initialisation code in the load or initialise event of your form. This code fills your text boxes and combo boxes.

I suggest you seperate out this code into a Private Function or Sub still within the same form which does this initialisation. You call this sub on the form load or initialise event, and you call it again on the click event of your command button. (This code should also clear the contents of combos before filling them so you don't fill it twice.)

Hope this is clear!

Dave.
 

technix

Active Member
Joined
May 19, 2002
Messages
326
On 2002-09-13 05:11, Helper monkey wrote:
Hi,

Is it possible to 'refresh' a userform or is the best option to unload and reload?

I have comboboxes and text boxes that i would like to be refreshed once used - i.e. once a commandbutton is clicked.

Thanks

Are you just trying to clear the textboxes, optionbuttons, and checkboxes? like a reset?

if so this will do it for you

Code:
Private Sub Reset_Click()
Dim ctl As Control

        For Each ctl In Userform_name_here.Controls
            If TypeName(ctl) = "TextBox" Then ctl.Text = Empty
            If TypeName(ctl) = "ComboBox" Then ctl.Text = Empty
            If TypeName(ctl) = "OptionButton" Then ctl.Value = False
        Next ctl

    TextBox1.SetFocus

End Sub

hth

Derrick
 

Forum statistics

Threads
1,144,217
Messages
5,723,063
Members
422,477
Latest member
pete101

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
Top