Updating unique values in Vlookup

后端 未结 1 461
梦如初夏
梦如初夏 2021-01-26 00:50

I have the below code, that uses \"UG list\" as the source and does vlookup on two different sheets - Latency and TT.

If the result is found it passes the string \"UG\"

相关标签:
1条回答
  • 2021-01-26 01:39

    Two things:


    1. You are using the same dictionary Dic for different sheets. Before using it for next sheet, clear the dictionary, so that you dont have any old values.

      dic.RemoveAll With Sheets("TT") .........


    1. To prevent the second updates, just remove the item from dictionary, as soon as as you find it first time. Though I am not sure what duplicate value you are referring to, as in dictionary you can't have duplicates.

      If dic.exists(cl.Value) Then
          Sheets("Latency").Cells(dic(cl.Value), 17) = "UG"
          dic.Remove (cl.Value)
      End If
      

    If you are just talking about the scenario where if the Column Q already has got "UG" in it and you want to skip that cell then just check it before hand.

      If dic.exists(cl.Value) Then
            If Sheets("Latency").Cells(dic(cl.Value), 17) <> "UG" Then
                Sheets("Latency").Cells(dic(cl.Value), 17) = "UG"
            End If
        End If
    
    0 讨论(0)
提交回复
热议问题