vba passing an array to a Dictionary.keys

Viewed 5856

i have an array of strings MyStrArray and i have a dictionary object MyDict

How do I pass MyStrArray to MyDict.keys Without looping? is it possible?

if i try MyDict.keys = MyStrArray I get an error "object Doesn't support this method" and the keys bounds are MyDict.Keys(0 to -1)i know what that means and i know i can loop through the array to fill the dict. as such (simple example)

on error resume next 
    for i= Lbound(MyStrArray) To Ubound(MyStrArray)
    MyDict.add key:=MyStrArray(i), item:=whatever
    next i

so, is there a way around that??

1 Answers
Related