ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clearing fields in Userform (https://www.excelbanter.com/excel-programming/404168-clearing-fields-userform.html)

WLMPilot

Clearing fields in Userform
 
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

RB Smissaert

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




All times are GMT +1. The time now is 06:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com