0

I'd like to go through list in Excel and assign the values to dictionary. The the dictionary will be put into list. This will happen until the cells in the column are blank. As a result of entire function, the array of dictionaries will be returned.

 Function CreateArrayofDicts()
    Dim catlist As Variant
    Dim catparams() As Variant
    Dim ChartParamsDict As Dictionary
    Dim k As Long
    catlist = ArrayProblemsCat()

    i = 1

    Do Until IsEmpty(Cells(i, 1))
        Set ChartParamsDict = New Scripting.Dictionary
        For j = 0 To UBound(catlist)
            Debug.Print Cells(i, 1)
            If Cells(i, 1) = catlist(j) Then
                Debug.Print 5
                ChartParamsDict.Add Key:="Cells(1,2)", Item:=Cells(i, 2)
                ChartParamsDict.Add Key:="Cells(1,3)", Item:=Cells(i, 3)
                ChartParamsDict.Add Key:="Cells(1,4)", Item:=Cells(i, 4)

                ReDim Preserve catparams(k)
                catparams(k) = ChartParamsDict ' issues is here
                k = k + 1
                Debug.Print ChartParamsDict
            End If

        Next j



    i = i + 1
    Loop
    CreateArrayofDicts = catparams
End Function
2
  • 1
    What is your question though? Are you having a problem with your code? Your are missing Set on the problem line. Also you are mixing up catlist and catparams Commented May 16, 2020 at 19:28
  • Thanks for the advice. Indeed I mixed them, but after adding Set it works fine Commented May 16, 2020 at 19:33

1 Answer 1

1

Your are missing Set on the problem line.

Set catparams(k) = ChartParamsDict
Sign up to request clarification or add additional context in comments.

Comments

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.