How to refresh a form?

47,430

Solution 1

Here is a very simple way. Simply Re-Initialze the Userform using the UserForm_Initialize

Private Sub UserForm_Initialize()
    TextBox1.Text = "" '<~~ Just an Example

    '
    '~~> Put here the code to re-initialize the userform which will refresh it
    '
End Sub

Private Sub CommandButton1_Click()
    TextBox1.Text = "Sid"

    MsgBox "Re-Initialzing the Userform"

    UserForm_Initialize
End Sub

Solution 2

Private Sub CommandButton1_Click()
    Unload Me
    UserForm1.Show
End Sub
Share:
47,430
HumanlyRespectable
Author by

HumanlyRespectable

Updated on December 28, 2020

Comments

  • HumanlyRespectable
    HumanlyRespectable over 3 years

    I have a userform with a button on it. I want the button to "refresh" the form, in other words I want the form to end, and then reopen.

    The code below won't work because the form/macro has already ended, but I want the button to perform this task or similar.

    sub command1.click()
    end
    userform1.show
    end sub
    

    I have checked and tried most or all the options I can choose from for a userform to "refresh". Is this even possible?

  • Taazar
    Taazar over 4 years
    Thanks for the code Panda but can you add a small description to let people know what it does or why you think this should solve the problem. Thanks.