Wildcard search of dictionary

前端 未结 4 1724
無奈伤痛
無奈伤痛 2020-12-11 21:23

After searching google and SO, I see that there is a way for me to search a dictionary for an existing key:

dict.exists(\"search string\")

4条回答
  •  暖寄归人
    2020-12-11 22:22

    this method can help you with wildcard searching in Dictionary

    Sub test()
    Dim Dic As Object: Set Dic = CreateObject("Scripting.Dictionary")
    Dim KeY, i&: i = 1
    For Each oCell In Range("A1:A10")
        Dic.Add i, Cells(i, 1).Value: i = i + 1
    Next
    For Each KeY In Dic
        If LCase(Dic(KeY)) Like LCase("Search*") Then
            MsgBox "Wildcard exist!"
            Exit For
        End If
    Next
    End Sub
    

提交回复
热议问题