none
check contents of combobox RRS feed

  • Question

  • hi,

    have vba code looping thru a range and adding items (if they exist) to combobox10. works fine!

    my question is: 

    how to add code so when loop is done 'if items are added then combobox10.listindex=0' else combobox10.value=""

    thanks

    Doug

    Monday, July 31, 2017 11:35 AM

Answers

  • Hi 6da4,

    ->if items are added then combobox10.listindex=0' else combobox10.value=""

    What do you want to do? Do you want to check if items are added into combo box items?

    You could check items count in combo box.

    If ComboBox1.ListCount > 0 Then

    ComboBox1.ListIndex = 0

    Else

    ComboBox1.Value = ""

    End If

    Best Regards,

    Terry

    • Marked as answer by 6da4 Wednesday, August 2, 2017 6:54 PM
    Tuesday, August 1, 2017 5:52 AM

All replies

  • On Error Resume Next
    ComboBox1.ListIndex = 0
    On Error GoTo 0



    Monday, July 31, 2017 3:01 PM
  • Hi 6da4,

    ->if items are added then combobox10.listindex=0' else combobox10.value=""

    What do you want to do? Do you want to check if items are added into combo box items?

    You could check items count in combo box.

    If ComboBox1.ListCount > 0 Then

    ComboBox1.ListIndex = 0

    Else

    ComboBox1.Value = ""

    End If

    Best Regards,

    Terry

    • Marked as answer by 6da4 Wednesday, August 2, 2017 6:54 PM
    Tuesday, August 1, 2017 5:52 AM