Determining whether an object is a member of a collection in VBA

前端 未结 15 1825
自闭症患者
自闭症患者 2020-11-27 05:35

How do I determine whether an object is a member of a collection in VBA?

Specifically, I need to find out whether a table definition is a member of the TableDe

15条回答
  •  被撕碎了的回忆
    2020-11-27 06:06

    Isn't it good enough?

    Public Function Contains(col As Collection, key As Variant) As Boolean
    Dim obj As Variant
    On Error GoTo err
        Contains = True
        obj = col(key)
        Exit Function
    err:
    
        Contains = False
    End Function
    

提交回复
热议问题