Dear all master,
please help for the problem in the VBA dictionary does not appear because the source is text and the result is a number which I marked in yellow and the other results appear because the source is text
please help for the problem in the VBA dictionary does not appear because the source is text and the result is a number which I marked in yellow and the other results appear because the source is text
VBA Code:
Sub Demo0301()
Dim Rng As Range, Ds As Range, n As Long, Dic As Object, Source As Variant
Dim Ary As Variant
Application.ScreenUpdating = False
With Sheets("IFG")
Source = .Range("B1").CurrentRegion.Offset(, 1).Resize(, 2)
End With
Set Dic = CreateObject("scripting.dictionary")
Dic.CompareMode = vbBinaryCompare
For n = 2 To UBound(Source, 1)
Dic(Source(n, 1)) = n
Next
With Sheets("MASTER")
Ary = .Range("c2", .Range("c" & Rows.Count).End(xlUp)).Value2
ReDim Nary(1 To UBound(Ary), 1 To 3)
For n = 1 To UBound(Ary)
If Dic.Exists(Ary(n, 1)) Then
Nary(n, 1) = Source(Dic(Ary(n, 1)), 2)
' Nary(n, 2) = Source(Dic(Ary(n, 1)), 3)
' Nary(n, 3) = Source(Dic(Ary(n, 1)), 4)
End If
Next n
Sheets("MASTER").Range("D2").Resize(UBound(Nary), 1).Value = Nary
End With