Consulting

Results 1 to 5 of 5

Thread: Solved: any way to clear textboxes on a userform?

  1. #1
    VBAX Regular
    Joined
    Sep 2007
    Posts
    16
    Location

    Solved: any way to clear textboxes on a userform?

    I have a userform that contains 2 comboboxes and 6 textboxes. I'd like the textboxes to clear everytime the combobox #2 selection is changed by a user. any ideas on how to do this?

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Private Sub ComboBox2_Change()
    With Me
    .TextBox1.Text = ""
    .TextBox1.Text = ""
    .TextBox2.Text = ""
    .TextBox3.Text = ""
    .TextBox4.Text = ""
    .TextBox5.Text = ""
    .TextBox6.Text = ""
    End With
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Sep 2007
    Posts
    16
    Location
    thanks! that works perfect. sorry if it was a common sense answer, im a newbie!

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    We all were once
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Master
    Joined
    Jun 2007
    Location
    East Sussex
    Posts
    1,110
    Location
    FYI, you could also use a loop like this if you have a lot of textboxes and you want them all cleared:
    [VBA] Dim ctl As Control
    For Each ctl In Me.Controls
    If TypeOf ctl Is MSForms.TextBox Then ctl.Text = ""
    Next ctl
    [/VBA]
    Regards,
    Rory

    Microsoft MVP - Excel

Posting Permissions

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