Hi,
I would need your help to create a macro for the following task.
In the attachment yuo can find sample workbook.
From sheet ("Main") I have values in cells B2:E2. I have to find the value of B2 in worksheet ("DB") and copy C2 and E2 to the related rows (column B and C) in ("db").
I tried the following without success:
Sub FindandCopy()
Dim ID As String
ID = Worksheets("MAIN").Range("B2").Value
For i = 1 To Worksheets("DB").Cells(Rows.Count, 1).End(xlUp).Row
If Worksheets("DB").Cells(i, 1).Value = ID Then
Worksheets("MAIN").Range("C2").Copy
Destination = Worksheets("MAIN").Cells(i, 2)
Worksheets("MAIN").Range("E2").Copy
Destination = Worksheets("MAIN").Cells(i, 3)
End If
Next i
End Sub
Bookmarks