Wildcard search of dictionary

前端 未结 4 1719
無奈伤痛
無奈伤痛 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:04

    If you want to use a wildcard to search in dictionary keys you can use the method [yourdictionary].Keys and the function Application.Match

    For example: Dim position As Variant 'It will return the position for the first occurrence

    position = Application.Match("*Gonzalez", phoneBook.Keys, 0)
    

    If phoneBook has Keys: (JuanCarlos, LuisGonzalez, PedroGonzalez)

    It will return the position for LuisGonzalez

提交回复
热议问题