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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
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.
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,904
Messages
6,122,169
Members
449,070
Latest member
webster33

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