Posts by popponator

    Pretty new to VBA except for basic import and formatting macros.


    I am trying to match a concatenated variant from sheet2 to sheet1, when I find a match copy from that ro columns E:J. I've tried several pieced together several tries at this and think I have come close. This macro runs with no errors but I am not getting any results either. Code posted below. What am I missing? it does everything I want except return results.




    Dim wsSource As Worksheet
    Dim wsMain As Worksheet
    Dim rngs As Variant
    Dim rngm As Variant
    Dim srow As Integer
    Dim mrow As Integer




    Set wsSource = Worksheets("Source")
    Set wsMain = Worksheets("Main")


    Set rngs = wsSource.Range("L2")
    Set rngm = wsMain.Range("L2")


    srow = 2
    mrow = 2


    'Clear old data
    wsMain.Range("D2:L1500").ClearContents
    wsSource.Range("L2:L1500").ClearContents


    wsMain.Range("L2:L" & Range("A65000").End(xlUp).Row).FormulaR1C1 = "=CONCATENATE(RC[-11],RC[-10],RC[-9])"
    wsSource.Range("L2:L" & Range("A65000").End(xlUp).Row).FormulaR1C1 = "=CONCATENATE(RC[-11],RC[-10],RC[-9])"



    Do While rngm.Offset(mrow, 0) <> "" Or rngm.Offset(mrow, 1) <> ""


    Do While rngs.Offset(srow, 0) <> ""

    If (rngs.Offset(srow, 0).Value = rngm.Offset(mrow, 0).Value) Then

    rngm.Offset(srow, -8).Value = rngs.Offset(mrow, -8).Value
    rngm.Offset(srow, -7).Value = rngs.Offset(mrow, -7).Value
    rngm.Offset(srow, -6).Value = rngs.Offset(mrow, -6).Value
    rngm.Offset(srow, -5).Value = rngs.Offset(mrow, -5).Value
    rngm.Offset(srow, -4).Value = rngs.Offset(mrow, -4).Value
    rngm.Offset(srow, -3).Value = rngs.Offset(mrow, -3).Value
    rngm.Offset(srow, -2).Value = rngs.Offset(mrow, -2).Value




    srow = srow + 1



    End If

    Loop
    mrow = mrow + 1