2

I want to declare something like so:

dictionaryItem = {("Key1", "Value1"}, {"Key2", "Value2"} ... }

But cannot get the syntax right. If not I'd like to make two arrays with initial values (but could not get this working either no matter how I tried to write it).

1 Answer 1

6

Seems to me you're describing a Scripting Dictionary. See if this is satisfactory.

Dim dct As Object
Set dct = CreateObject("Scripting.Dictionary")
dct.Add "Key1", "Value1"
dct.Add "Key2", "Value2"
Debug.Print dct.Count
Debug.Print dct("Key1")
Debug.Print dct("Key2")
Set dct = Nothing
Sign up to request clarification or add additional context in comments.

2 Comments

Can you use a list of values instead of a single value?
A dictionary will accept an array for the item value, but not for the key.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.