Ako_____
11-02-2012, 02:17 PM
Hi,
I am still a rookie at VBA and I could really use a little help from some of you big brainers!
I am currently making a userform with some textboxes and comboboxes. What I want to do is to have an initial value in ComboBox1 and then let the value in TextBox1 depend on it.
Every time I try this I am getting an error unless I erase the line saying "If ComboBox1.Value = "S235" Then TextBox1.Value = 235 / 2".
Does anyone know how to solve this problem?
I would really appreciate some help :)
Private Sub UserForm_initialize()
With ComboBox1
.AddItem "S235"
.AddItem "S275"
.AddItem "S355"
End With
ComboBox1.ListIndex = 0
ComboBox1.Style = fmStyleDropDownList
End Sub
Private Sub ComboBox1_Change()
If ComboBox1.Value = "S235" Then TextBox1.Value = 235 / 2
If ComboBox1.Value = "S275" Then TextBox1.Value = 275 / 2
If ComboBox1.Value = "S355" Then TextBox1.Value = 355 / 2
End Sub
I am still a rookie at VBA and I could really use a little help from some of you big brainers!
I am currently making a userform with some textboxes and comboboxes. What I want to do is to have an initial value in ComboBox1 and then let the value in TextBox1 depend on it.
Every time I try this I am getting an error unless I erase the line saying "If ComboBox1.Value = "S235" Then TextBox1.Value = 235 / 2".
Does anyone know how to solve this problem?
I would really appreciate some help :)
Private Sub UserForm_initialize()
With ComboBox1
.AddItem "S235"
.AddItem "S275"
.AddItem "S355"
End With
ComboBox1.ListIndex = 0
ComboBox1.Style = fmStyleDropDownList
End Sub
Private Sub ComboBox1_Change()
If ComboBox1.Value = "S235" Then TextBox1.Value = 235 / 2
If ComboBox1.Value = "S275" Then TextBox1.Value = 275 / 2
If ComboBox1.Value = "S355" Then TextBox1.Value = 355 / 2
End Sub