PDA

View Full Version : [SOLVED:] Compare 2 colums of different sheet and copy values for matching data



RIC63
02-02-2017, 09:57 AM
Can anyone give me an indication of how to approach the problem described in the attached file


Thanks in advance

mike7952
02-02-2017, 02:50 PM
This will work

Sub abc()
Const shFoglio1 As String = "Foglio1"
Const shFoglio2 As String = "Foglio2"

With Worksheets(shFoglio1)
For i = 6 To .Cells(Rows.Count, "c").End(xlUp).Row
.Cells(i, "J").Value = _
Evaluate("=INDEX(" & shFoglio2 & "!E:E,MATCH(" & shFoglio1 & "!C" & i & "," & shFoglio2 & "!A:A,0))")
Next
End With
End Sub

RIC63
02-05-2017, 01:21 AM
thanks mike7952


such a short code that does what I wanted ... for me it is magic !! :-)


the only thing I noticed is that the copied cell does not keep source formatting

in any case, thanks again

mml
09-18-2019, 11:53 PM
Looking at I though that it may solve my problem of matching . Downloaded the file and added as a module but get an error "value not defined" on For i . I thought it was a simple add module then run ... what am I doing wrong?
25112