Home

Published

- 1 min read

excel vba check if key is in collection

img of excel vba check if key is in collection

The solution for this is noted below

excel vba check if key is in collection

Solution

   'A Dictionary is a better choice when you need to determine if a key
'is already in the collection. But here is a VBA function that
'reports True or False for Collections:

Function KeyExists(key$, c As Collection)
  On Error Resume Next
  c.Item key
  KeyExists = Err = 0: Err.Clear
End Function

'--------------------------------------------------------------------

MsgBox KeyExists("Netflix", colFANG)

Try other methods by searching on the site. That is if this doesn’t work