How can I seek key of dictionary by index value?

calendar_today Asked Dec 17, 2010
thumb_up 10 upvotes
history Updated April 16, 2026

Question posted 2010 · +3 upvotes

How can I get the key of a dictionary by passing the index value?

I’m trying:

If rs.Fields("NM").Value = dictNM.key(0)

that is, I want it to compare to the first key in the dictionary

but I get the error

Compile error: Invalid use of property

I tried googling, but to no avail. I’m hoping this is even possible.

Accepted answer +10 upvotes

You should be able to use the Keys property:

dictNM.Keys(0)

Edit:
One thing to keep in mind is that the order of the keys is unspecified, see MSDN

Top excel Q&A (6)

+10 upvotes ranks this answer #78 out of 167 excel solutions on this site .