简体   繁体   中英

How can I use vba to tell if an Active X combobox on an excel sheet has an a list

How can I use vba to tell if an Active X combobox on an excel sheet has a list with items in it.

The following returns an error if the combobox has nothing in it's list:

if UBound(MyComboBox.List, 1) > 1 then

and the following returns an error if there are items in the list:

if MyComboBox.List <> Null then

Cheers!

Oliver.

The following code with check if there are items in the ComboBox1 and list all the items it finds:

Dim lngRow As Long

If ComboBox1.ListCount > 0 Then
    For lngRow = 0 To ComboBox1.LineCount - 1
        Debug.Print ComboBox1.List(lngRow , 0)
    Next intRow
End If

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM