View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
RB Smissaert RB Smissaert is offline
external usenet poster
 
Posts: 2,452
Default Clearing fields in Userform

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



"WLMPilot" wrote in message
...
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