OzGrid

How to clear Userform

< Back to Search results

 Category: [Excel]  Demo Available 

How to clear Userform

 

Requirement:

 

 The user has  a CLEAR FORM command button and would like to know what codes to use so that when the user clicks CLEAR FORM, all the data that was previously encoded in the textboxes of the current userform will be erased and a new form provided.

 

Solution:

 

Code:
Dim oCtrl As Control
For Each oCtrl In Me.Controls
    If TypeOf oCtrl Is MSForms.TextBox Then   
        oCtrl.Text = ""
    End If
Next oCtrl

 

 

Obtained from the OzGrid Help Forum.

Solution provided by royUK.

 

See also: Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions and Index to new resources and reference sheets

 

See also:

How to print userform in orientation landscape
How to use Excel VBA userform list box
How to use a single 'date field' for various items in a data entry userform
How to create data entry userforms
How to use a UserForm: CheckBox Checked if Listbox column 5 text matched CheckBox text

 

Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.


Gallery



stars (0 Reviews)