Consulting

Results 1 to 2 of 2

Thread: Yes/No combo box

  1. #1

    Yes/No combo box

    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

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    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

Posting Permissions

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