Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to clear items on a form?
Hi,
I have a user form with details such as first name and last name. IF the user wishes to start again, I would like a clear or reset button to clear the fields that they have typed. Is there a way to loop through each textbox to clear it to blank? Thanks G |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to clear items on a form?
G,
Grd wrote: I have a user form with details such as first name and last name. IF the user wishes to start again, I would like a clear or reset button to clear the fields that they have typed. Is there a way to loop through each textbox to clear it to blank? Here's one way: Private Sub ClearAll() Dim ctl As Control For Each ctl In Controls If TypeOf ctl Is MSForms.TextBox Then ctl.Object.Text = "" End If Next ctl End Sub -- Regards, Jake Marx www.longhead.com [please keep replies in the newsgroup - email address unmonitored] |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to clear items on a form?
It's not elegant, but assuming you name all your TextBox controls
consistently (i.e. begin with txt) then the following will work. Dim ctrl As Control For Each ctrl In UserForm1.Controls If Left(ctrl.Name, 3) = "txt" Then ctrl.Text = "" End If Next Just add this to the Click event of a button on your UserForm. "Grd" wrote: Hi, I have a user form with details such as first name and last name. IF the user wishes to start again, I would like a clear or reset button to clear the fields that they have typed. Is there a way to loop through each textbox to clear it to blank? Thanks G |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
order form with multiple items and sizes for items | Excel Discussion (Misc queries) | |||
How to clear a form from the screen | Excel Programming | |||
2nd Form deselects list box items on main form | Excel Programming | |||
Help with a Clear Form Macro | Excel Programming | |||
clear the Form | Excel Programming |