dimanche 9 février 2020

i want to inplement multiple words in left condition

Ihave written a if condition using left condition, that if the cell first 3 characters are "CAK" then copy the cell and paste it to another sheet. it worked successfully, but now i want to search for 5, 6 words to search like "CAK", "BDD, "GHH", "BAK", "GHH", Can any one tell me how to keep multiple words,

I want VBA code like if the cell first 3 characters are "CAK" or "BDD" or "GHH" or "BAK" or "GHH" then copy and paste.

Sub NOTES()

For C = 27 To 33

    A = Worksheets("EDAT").Cells(Rows.Count, 1).End(xlUp).Row

    For I = 12 To A

    Worksheets("EDAT").Activate
    Worksheets("EDAT").Cells(I, C).Activate

     If (Left(ActiveCell, 3) = "CAK") Then
        Worksheets("sheet1").Cells(I, C).COPY
        Worksheets("sheet2").Activate
        b = Worksheets("sheet2").Cells(Rows.Count, 1).End(xlUp).Row
        Worksheets("sheet2").Cells(b + 1, 1).Select
        ActiveSheet.Paste
        Worksheets("sheet1").Cells(I, 10).COPY
        Worksheets("sheet2").Activate
        Worksheets("sheet2").Cells(b + 1, 8).Select
        ActiveSheet.Paste
        Worksheets("sheet1").Cells(I, 11).COPY
        Worksheets("sheet2").Activate
        Worksheets("sheet2").Cells(b + 1, 9).Select
        ActiveSheet.Paste
    End If

    Next

Next

End Sub

Aucun commentaire:

Enregistrer un commentaire