# [Solved] Copy cell values from one excel workbooks sheet to another when a cell value matches in the same row

You’ve literally not provided any code that you’ve attempted to use to do this, more people would gladly help if you would have at least attempted to code it…
Nonetheless, you did not provide your sheet names, here is some code you can put to the test.

``````Sub CopyValue

Dim Wb1 As Workbook, wb2 As Workbook, lastrow As Long, lastrow2 As Long, counter As Integer

counter = 0
Set wb1 = Workbooks("wb01")
Set wb2 = Workbooks("wb02")
lastrow = wb1.Range("A" & .Rows.Count).End(xlUp).Row
lastrow2 = wb2.Range("A" & .Rows.Count).End(xlUp).Row

For x = 2 To lastrow
For y = 2 To lastrow2
If wb1.Sheets("abc").Cells(x,1).Value = wb2.Sheets("def").Cells(y,1).Value Then
wb2.Sheets("def").Cells(y,2).Value =    wb1.Sheets("abc").Cells(x,2).Value
wb2.Sheets("def").Cells(y,3).Value =    wb1.Sheets("abc").Cells(x,3).Value
Else
counter= counter +1
wb2.Sheets("def").Cells(lastrow+counter,1).Value = wb1.sheets("abc").Cells(x,1).Value
wb2.Sheets("def").Cells(lastrow+counter,2).Value = wb1.sheets("abc").Cells(x,2).Value
wb2.Sheets("def").Cells(lastrow+counter,3).Value = wb1.sheets("abc").Cells(x,3).Value
End If
Next y
Next x
End Sub
``````

solved Copy cell values from one excel workbooks sheet to another when a cell value matches in the same row