clear the Form

  • Thread starter Thread starter Guest
  • Start date Start date
There isn't built-in way to clear a user forms controls back to
their default state. You would have to loop through the Controls
collection and reset the controls, or do each one individually.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
What do you mean by form - Userform with controls, or a worksheet made to
look like a paper form.

What do you want to clear. Be specific.

The basic approach would be to loop through the items containing entries and
clear them individually.
 
The following code will clear out the text boxes on a form. You
can adapt the code for other types of controls.

Private Sub CommandButton1_Click()
Dim C As MSForms.Control
For Each C In Me.Controls
If TypeOf C Is MSForms.TextBox Then
C.Text = ""
End If
Next C
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Unload it, then show it again.

Don't try to reshow it from its own event code - have the original calling
routine show it again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top