kashif.special2005
Active Member
- Joined
- Oct 26, 2009
- Messages
- 443
Hi,
I am applying vlookup functionality through Dictionary object, and it is working fine if the lookup value is less than or equal to 70000, I am holding lookup data in the variable "mydata2", but if the lookup value is more than like 80000, it is giving my an "Type Mismatch" error in the below line.
Range("B2").Resize(UBound(mydata3), 1).Value = Application.Transpose(mydata3)
Note:- In Dictionary object I am apply vlookup like functionality in memory and it is running fast., and vlookup is taking more time to calculate.
Please help me where I am doing wrong.
Thanks
Kashif
I am applying vlookup functionality through Dictionary object, and it is working fine if the lookup value is less than or equal to 70000, I am holding lookup data in the variable "mydata2", but if the lookup value is more than like 80000, it is giving my an "Type Mismatch" error in the below line.
Range("B2").Resize(UBound(mydata3), 1).Value = Application.Transpose(mydata3)
Note:- In Dictionary object I am apply vlookup like functionality in memory and it is running fast., and vlookup is taking more time to calculate.
Code:
Sub UseDictionary()
' Get the range of values
Dim rg As Range
Dim mydata As Variant
Dim mydata2 As Variant
Dim mydata3() As Variant
Dim mytime As Date
mytime = Now
mydata = Sheet1.Range("A2:B500001").Value
mydata2 = Sheet2.Range("A2:a80000")
' Create the dictionary
Dim dict As Object
Set dict = CreateObject("Scripting.Dictionary")
For i = LBound(mydata, 1) To UBound(mydata, 1)
dict(mydata(i, 1)) = mydata(i, 2)
Next i
ReDim mydata3(1 To UBound(mydata2))
For i = LBound(mydata2, 1) To UBound(mydata2, 1)
mydata3(i) = dict(mydata2(i, 1))
Next i
Range("B2").Resize(UBound(mydata3), 1).Value = Application.Transpose(mydata3)
MsgBox Format(Now - mytime, "hh:mm:ss")
End Sub
Please help me where I am doing wrong.
Thanks
Kashif