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

前端 未结 15 1845
自闭症患者
自闭症患者 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:18

    I have some edit, best working for collections:

    Public Function Contains(col As collection, key As Variant) As Boolean
        Dim obj As Object
        On Error GoTo err
        Contains = True
        Set obj = col.Item(key)
        Exit Function
        
    err:
        Contains = False
    End Function

提交回复
热议问题