Copy cell to one of two worksheets based on if criteria

  • Hello


    I have two variations of order id's that I want to move into separate worksheets based on if the if contains a dash (-) or not.
    So if the orderId in sheets "Forside" does not have (-) in it, should be moved to sheet "BPB" A1 and the next should be moved to A2 and so on.
    Does the orderId contain a (-) should it go to sheet "BP" starting for A1 and so on.


    This is what a got so far and it doesn't work:



    Sub TestCopyPaste3()
    Dim c As Range
    for each c in worksheet("Forside").range("B2", range("B2").End(xlDown).Cells

    If c Like "*-*" Then
    c.Copy Destination:=Worksheets("BP").Range("A2", Range("A2").End(xlDown)

    Else
    c.Copy Destination:=Worksheets("BPB").Range("A2", Range("A2").End(xlDown)
    End If



    Link to workbook: https://drive.google.com/file/…RGre79hX/view?usp=sharing


    Any help is appreciated
    Thanks :)

  • Try:

    You can say "THANK YOU" for help received by clicking the "Like" icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!