문제

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?

도움이 되었습니까?

해결책

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

다른 팁

Private Sub CommandButton1_Click()
    Unload Me
    UserForm1.Show
End Sub
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top