Cmbobox and textBox

eliking510

New Member
Joined
Mar 2, 2011
Messages
15
Hey...!

I have a UserForm with 1 combobox and 2 textBoxes.
When i will choose a specifiq value from the combobox, i want a third textbox to be added .

Example : I have these values in the combo => "home", "Office" & "Other"
when i will choose "Other" , I want a textbox to be added
in (a third one)

Can anyone help me ??
Thank You ! :):rolleyes:
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Hi there,

Rather than add the textbox, might I suggest you just change its visibility?

Mark
 
Upvote 0
Hi there,

Rather than add the textbox, might I suggest you just change its visibility?

Mark


-------------------------------
I thought about it, but i don't know how to do that
I want that the textbox will be visible only if choose a specific value from the combobox

thank you :cool:
 
Upvote 0
A simple example, but see if this gets you started.

In a blank/new wb, add a userform with one combobox and three textboxes, default names to all. You can see that we use the form's initialize event to initially hide the one textbox, as well as populate the combobox and layout the controls.

You can try using the combobox's change event to hide/display the textbox.

Rich (BB code):
Option Explicit
    
Private Sub ComboBox1_Change()
    TextBox3.Visible = ComboBox1.Value = "Two"
End Sub
    
Private Sub UserForm_Initialize()
    
    With Me
        With ComboBox1
            .AddItem "One"
            .AddItem "Two"
            .AddItem "Three"
            .Height = 16
            .Left = 12
            .Style = fmStyleDropDownList
            .Top = 12
        End With
        With TextBox1
            .Height = 16
            .Left = 12
            .Top = 34
        End With
        With TextBox2
            .Height = 16
            .Left = 12
            .Top = 56
        End With
        With TextBox3
            .Height = 16
            .Left = 12
            .Top = 78
            .Visible = False
        End With
    End With
End Sub
Hope that helps,

Mark
 
Upvote 0
A simple example, but see if this gets you started.

In a blank/new wb, add a userform with one combobox and three textboxes, default names to all. You can see that we use the form's initialize event to initially hide the one textbox, as well as populate the combobox and layout the controls.

You can try using the combobox's change event to hide/display the textbox.

Rich (BB code):
Option Explicit
 
Private Sub ComboBox1_Change()
    TextBox3.Visible = ComboBox1.Value = "Two"
End Sub
 
Private Sub UserForm_Initialize()
 
    With Me
        With ComboBox1
            .AddItem "One"
            .AddItem "Two"
            .AddItem "Three"
            .Height = 16
            .Left = 12
            .Style = fmStyleDropDownList
            .Top = 12
        End With
        With TextBox1
            .Height = 16
            .Left = 12
            .Top = 34
        End With
        With TextBox2
            .Height = 16
            .Left = 12
            .Top = 56
        End With
        With TextBox3
            .Height = 16
            .Left = 12
            .Top = 78
            .Visible = False
        End With
    End With
End Sub
Hope that helps,

Mark
-----------------------------------
Thanks A lot !! it works !!;)
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,850
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top