Consulting

Results 1 to 4 of 4

Thread: Compare 2 colums of different sheet and copy values for matching data

  1. #1
    VBAX Regular
    Joined
    Jan 2015
    Posts
    92
    Location

    Compare 2 colums of different sheet and copy values for matching data

    Can anyone give me an indication of how to approach the problem described in the attached file


    Thanks in advance
    Attached Files Attached Files

  2. #2
    VBAX Regular
    Joined
    Dec 2016
    Posts
    29
    Location
    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

  3. #3
    VBAX Regular
    Joined
    Jan 2015
    Posts
    92
    Location
    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

  4. #4
    VBAX Regular
    Joined
    Aug 2019
    Posts
    56
    Location
    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?
    Compile error .jpg

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •