mercredi 8 janvier 2020

VBA Copy and Paste function where two criteria are met

I am brand new to VBA coding and am confused on how I would be able to copy and paste values from one sheet to another if two criteria points are met. In the sheet below I want to copy "12, 9, and 15" and paste it into the "Expected, P10 and P90" cells on sheet2 if the names on sheet one "Orange, Green" match those on sheet 1.

enter image description here

enter image description here

I've been attempting this on my own for quite some time now with now luck.

Attached is the code I started

Sub Copy_Certain_Data()

    a = Worksheets("Schedule Results").Cells(Rows.Count, 1).End(xlUp).Row


    For i = 3 To a

    If Worksheets("Schedule Results").Cells(i, 3).Value = "NE2P1" Then

    Worksheets("schedule results").Rows(i).Copy

    Worksheets("Campaign 1 Data").Activate

    Range("F2").Select

    ActiveSheet.Paste

    Worksheets("Schedule Results").Activate

    End If
    Next

    Application.CutCopyMode = False

End Sub

Aucun commentaire:

Enregistrer un commentaire