I`m having the following challenge. In my initial file there are 3 cells (for example a1,b1 and c1) named A, B and C. In the target file there are numerous letters in one column. I need to find the row containing a, b and c in the target file, and copy the value that is 2 cells to the right back into the initial file into the corresponding cell ( so the value from A next to A and so on).
I got this to work when using only 1 workbook with the following code:
in this workbook the range A1:A3 functions as "initial file" and colum C as "target file" with column D holding the value that needs to be pasted back to A1:A3. The problem is i cant get this to work when the C and D column are in another file
Sub CopyC()
Dim value As String
Dim SrchRng As Range, cel As Range
Dim NbD
number_of_days = Array("A", "B", "C")
For Each NbD In number_of_days
last_row = Cells(Rows.Count, "C").End(xlUp).Row
For current_row = 1 To last_row ' start of loop
If Cells(current_row, "") = NbD Then
value = Cells(current_row, "D")
waarde = Cells(current_row, "C")
If value <> "" Then
Set SrchRng = Range("A1:A3")
For Each cel In SrchRng
If cel.value = waarde Then
cel.Offset(0, 1).value = value
End If
Next cel
End If
End If
Next current_row
Next NbD
End Sub
Bookmarks