Clearing fields in Userform

W

WLMPilot

Is there an easy way to clear all fields in a userform (textboxes and
comboboxes)?
I have about 26 fields of text or combo boxes and wanted to see if there is
just a command to "clear" userform.

Thanks,
Les
 
R

RB Smissaert

See if this works for you:

Sub test()

Dim ctl As MSForms.Control

For Each ctl In Form1.Controls
Select Case TypeName(ctl)
Case "TextBox"
MainForm.Controls(ctl.Name).Text = vbNullString
Case "CheckBox"
MainForm.Controls(ctl.Name).Value = False
Case "OptionButton"
MainForm.Controls(ctl.Name).Value = False
End Select
Next ctl

End Sub


RBS
 

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

Top