Error This key is already associated with an element of this collection

前端 未结 3 1542
孤城傲影
孤城傲影 2021-01-02 04:10

I am working on vba macros. I was trying to use a dictionary. But it is giving error 457 with debugger pointing to toprow.Add ActiveCell.value, val

3条回答
  •  抹茶落季
    2021-01-02 04:54

    I was getting the same error message: "Error This key is already associated with an element of this collection". In my case, the problem was that I had this:

    'assign values to properties
    Property Let EmployeeName(Valor As String)
        m_employeename = Valor
    End Property
    Property Let EmployeeID(Valor As String)
        m_employeename = Valor
    End Property
    

    I was supposed to have this:

    'assign values to properties
    Property Let EmployeeName(Valor As String)
        m_employeename = Valor
    End Property
    Property Let EmployeeID(Valor As String)
        m_employeeid = Valor
    End Property
    

    Maybe you just have to double check your "Property Let" code to see if you are using appropriate names for those variables that are private in your class.

提交回复
热议问题