Code: Select all
Sub CompareCols()
Application.ScreenUpdating = False
Dim LastRow As Long, Val As String, ws1 As Worksheet, ws2 As Worksheet, i As Long, v1, v2, RngList As Object
LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Set ws1 = ThisWorkbook.Sheets("Sheet1")
Set ws2 = Sheets("Sheet2")
v1 = ws1.Range("A2", ws1.Range("A" & Rows.Count).End(xlUp)).Resize(, 4).Value
v2 = ws2.Range("B1", ws2.Range("B" & Rows.Count).End(xlUp)).Resize(, 10).Value
Set RngList = CreateObject("Scripting.Dictionary")
For i = 1 To UBound(v2, 1)
Val = v2(i, 1)
If Not RngList.Exists(Val) Then
RngList.Add Val, Nothing
End If
Next i
For i = 1 To UBound(v1, 1)
Val = v1(i, 1)
If RngList.Exists(Val) Then
ws1.Cells(i + 1, 4) = v2(i, 10)
End If
Next i
Application.ScreenUpdating = True
End Sub
this code is not working as i wanted plz see the file which i have attached
it should paste the correct data but it is pasting incorrect data
Plz see the attachments
If column A of sheet1 matches with column B of sheet2 then copy column K data of sheet2 & paste it to column D of sheet1 & save the changes
I need the macro of the same
Output after runing the macro is pasted in sheet3 plz have a look(Only for understanding purpose it is putted in sheet3)
https://drive.google.com/open?id=1VtG-p ... qivrOtbMb5