nightheart
New Member
- Joined
- Feb 9, 2012
- Messages
- 10
Hi All,
The code below used to be running fine but suddenly it started giving me the following error: "Run-time error 457:This key is already associated with an element of this collection."
Would you please help with such error as I couldn't find why it is doing that.
The error pops up at the line in red above.
Thanks
The code below used to be running fine but suddenly it started giving me the following error: "Run-time error 457:This key is already associated with an element of this collection."
Would you please help with such error as I couldn't find why it is doing that.
Code:
Dim x
Set dic = CreateObject("Scripting.dictionary")
With Sheets("Test")
For Each r In .Range("a2", .Range("a65536").End(xlUp))
If r = Me.cmbcategory.Value And r.Offset(, 2) _
= Me.cmbname.Value Then
If Not dic.exists(r.Offset(, 5).Value) Then
dic.Add r.Offset(, 5).Value, Nothing
[COLOR="Red"]dic.Add r.Offset(, 6).Value, Nothing[/COLOR]
Me.cmbprice.AddItem r.Offset(, 5)
Me.cmbserial.AddItem r.Offset(, 6)
ReDim Preserve m_price(m_long) As Variant
ReDim Preserve m_serial(m_long) As Variant
m_price(m_long) = r.Offset(, 5)
m_serial(m_long) = r.Offset(, 6)
m_long = m_long + 1
End If
End If
Next
End With
End Sub
The error pops up at the line in red above.
Thanks