Consulting

Results 1 to 3 of 3

Thread: ComboBox Additem Duplicates

  1. #1

    ComboBox Additem Duplicates

    Hi

    Im am doing a PowerPoint 2010 presentation where i want to have a dropdown combobox with the 4 different options.
    My code looks accordingly:

    Private Sub ComboBox1_DropButtonClick()
    ComboBox1.AddItem ""
    ComboBox1.AddItem "Passed"
    ComboBox1.AddItem "Not Passed"
    ComboBox1.AddItem "Follow-Up"

    End Sub

    However, my problem is that when i choose an option the dropdown list gets filled with the same options 3 times i.e. the options are trippled. (see attachment) Every time i choose an option the list gets extended further with the same options. How do i avoid this?
    Scroll.png

    would appreciate fast help

  2. #2
    I have figured it out now and my code now looks like this:
    Private Sub ComboBox1_DropButtonClick()
    If ComboBox1.ListCount < 4 Then
    ComboBox1.AddItem ""
    ComboBox1.AddItem "Passed"
    ComboBox1.AddItem "Not Passed"
    ComboBox1.AddItem "Follow-Up"
    End If
    End Sub

    However, i now have another issue and that is I want to have a different text colour for each option i.e. Passed should be in green text, Not Passed in red and Follow-Up in blue. Is that possible and how can you do that?

  3. #3
    VBAX Contributor
    Joined
    May 2008
    Posts
    198
    Location
    A better solution would be to clear the items before adding them

    Combobox1.Clear
    ComboBox1.AddItem ""
    ComboBox1.AddItem "Passed"
    ComboBox1.AddItem "Not Passed"
    ComboBox1.AddItem "Follow-Up"

    I don't believe the list items can have different formatting.

Posting Permissions

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