can anyone help me.i need when a combo box with value "yes/no" will calculate a field.Example is when i chose "yes" it will calculate 10% from the a price if the user choose "no" then no percentage reduction.This have to be done in userform.thx
can anyone help me.i need when a combo box with value "yes/no" will calculate a field.Example is when i chose "yes" it will calculate 10% from the a price if the user choose "no" then no percentage reduction.This have to be done in userform.thx
You can make the ComboBox with a Rowsource that has Yes, and No, or you can use ComboBox1.AddItem "Yes" for example.
Then you just need to check the value of this on the change event for the ComboBox.
[vba]
Option Explicit
Private Sub ComboBox1_Change()
If Me.ComboBox1.Text = "Yes" Then
Me.TextBox2.Value = Val(Me.TextBox1.Value) * 0.9
Else
Me.TextBox2.Value = Val(Me.TextBox1.Value)
End If
End Sub
Private Sub UserForm_Initialize()
Me.ComboBox1.AddItem "Yes"
Me.ComboBox1.AddItem "No"
End Sub
[/vba]
See Attachment