我如何使用 vba 判断 excel sheet 上的 Active X 组合框是否有列表

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

我如何使用 vba 判断 excel sheet 上的 Active X 组合框是否有包含项目的列表。

如果组合框的列表中没有任何内容,则以下 returns 错误:

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

和以下 returns 如果列表中有项目则出错:

if MyComboBox.List <> Null then

干杯!

奥利弗

以下代码检查 ComboBox1 中是否有项目并列出它找到的所有项目:

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