0
我有下面的代碼,它使用「UG list」作爲源代碼,並在兩張不同的工作表上進行vlookup - 延遲和TT。在Vlookup中更新唯一值
如果找到結果,它會將字符串「UG」傳遞到每張紙的特定列上。
問題是即使有重複值的字符串「UG」得到更新..但我想要的是,「UG」應該更新爲唯一值..它不應該再次更新爲相同的值,並且再次。
Sub vlookup()
Dim cl As Range, Dic As Object
Set Dic = CreateObject("Scripting.Dictionary"): Dic.Comparemode = vbTextCompare
With Sheets("Latency")
For Each cl In .Range("B2:B" & .Cells(Rows.count, "C").End(xlUp).Row)
If Not Dic.exists(cl.Value) Then Dic.Add cl.Value, cl.Row
Next cl
End With
With Sheets("UG list")
For Each cl In .Range("A2:A" & .Cells(Rows.count, "A").End(xlUp).Row)
If Dic.exists(cl.Value) Then
Sheets("Latency").Cells(Dic(cl.Value), 17) = "UG"
End If
Next cl
End With
With Sheets("TT")
For Each cl In .Range("A2:A" & .Cells(Rows.count, "C").End(xlUp).Row)
If Not Dic.exists(cl.Value) Then Dic.Add cl.Value, cl.Row
Next cl
End With
With Sheets("UG list")
For Each cl In .Range("A2:A" & .Cells(Rows.count, "A").End(xlUp).Row)
If Dic.exists(cl.Value) Then
Sheets("TT").Cells(Dic(cl.Value), 23) = "UG"
End If
Next cl
End With
Set Dic = Nothing
End Sub