+ Reply to Thread
Results 1 to 4 of 4

Clear all text boxes-combo boxes in a userform.

Hybrid View

  1. #1
    Forum Contributor MariaPap's Avatar
    Join Date
    10-19-2013
    Location
    Chania-Crete-Greece
    MS-Off Ver
    Excel 2003-2010
    Posts
    319

    Clear all text boxes-combo boxes in a userform.

    Hello

    Apologize in advance if the answer of my question is simple..

    I use many series of textboxes and compo boxes in my userforms.

    Until now i use something like this to clear the data into these.

    qucase1.Value = ""
    qucase2.Value = ""
    qucase3.Value = ""
    qucase4.Value = ""
    qucase5.Value = ""
    
    prcase1.Value = ""
    prcase2.Value = ""
    prcase3.Value = ""
    prcase4.Value = ""
    prcase5.Value = ""
    
    valcase1.Value = ""
    valcase2.Value = ""
    valcase3.Value = ""
    valcase4.Value = ""
    valcase5.Value = ""
    
    machcase1.Value = ""
    machcase2.Value = ""
    machcase3.Value = ""
    machcase4.Value = ""
    machcase5.Value = ""
    
    comcase1.Value = ""
    comcase2.Value = ""
    comcase3.Value = ""
    comcase4.Value = ""
    comcase5.Value = ""
    
    TextBox15.Value = ""
    TextBox4.Value = ""
    ComboBox1.Text = ""
    It's really hard..

    Is there any other way to clear ALL the qucases, ALL the prcases...etc using 1 line of code?

    Thanks in advance for any assistance here!

  2. #2
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Clear all text boxes-combo boxes in a userform.

    One very simple method would be to unload and reload the userform.

    Unload Me 
    UserForm1.Show
    Elegant Simplicity............. Not Always

  3. #3
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Clear all text boxes-combo boxes in a userform.

    if for some reason you don't want to unload/show form another way is to loop trough the controls and check their type. In the code I assume your form name is UserForm1

    Sub ClearTextAndComboBoxes()
        Dim objControl As MSForms.Control
            For Each objControl In UserForm1.Controls 'change the name of the form
                If TypeOf objControl Is MSForms.TextBox Or TypeOf objControl Is MSForms.ComboBox Then
                    objControl.Value = vbNullString
                End If
            Next objControl
    End Sub
    If you are pleased with a member's answer then use the Star icon to rate it.

  4. #4
    Forum Contributor MariaPap's Avatar
    Join Date
    10-19-2013
    Location
    Chania-Crete-Greece
    MS-Off Ver
    Excel 2003-2010
    Posts
    319

    Re: Clear all text boxes-combo boxes in a userform.

    buran


    Thank you. This does exactly what i need!!

    Andy thanks for the assist here!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Help with code for userform text boxes, combo boxes and excel
    By innerise in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-20-2014, 09:07 AM
  2. Using the If function to set parameters on Text and Combo boxes on a userform
    By jtemp57 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-14-2014, 11:42 AM
  3. Selected data from combo boxes to text boxes
    By soulun in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-22-2013, 06:48 AM
  4. Combo Boxes / Text Boxes Not Updating
    By ckk403 in forum Excel General
    Replies: 4
    Last Post: 01-09-2012, 08:22 AM
  5. Auto populating UserForm Combo and Text boxes from Validated data sets
    By ZIXILPLIX in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-04-2010, 12:55 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1