Copy Data based on two criteria

  • have data that has been imported on sheet "Data"



    I need to copy data as follows to sheet "Stock received"



    1) Where COL I contains RS and Col H does not contain "not received", then I need Col B:H copied to sheet Stock Received into Row 4 onwards
    2) Where COL I contains NR and Col H does not contain "not received", then I need Col B:H copied to sheet Stock Received into Row 21 onwards



    Your assistance in this regard is most appreciated



    I have also posted two days ago on http://windowssecrets.com/foru…ata-based-on-two-criteria

  • Re: Copy Data based on two criteria


    Try this:



    Just note that if the first block (i.e. Code RS on the Stock Received tab) gets filled the pasting of the data from then on will be out of sync.


    Regards,


    Robert

  • Re: Copy Data based on two criteria


    Have Tested Code & it works perfectly


    If my source sheets consisted of several sheet,s How do change Set wsSource = Sheets("Data") to incorporate these ? for eg sheets "Data", "Data1", "Data2", "Data3"

  • Re: Copy Data based on two criteria


    Try this:


  • Re: Copy Data based on two criteria


    Hi, I had a worksheet something similar to the above request. If I had several Destination worksheet labelled under Code instead. the code will copy and paste to the worksheet named after the value in cell "Code". The place to copy to will be the row below the cell in column A equal to "Insert". However the code will insert a new row before paste over. Appreciate someone can help.

  • Re: Copy Data based on two criteria


    Hi kaffal,


    We're glad to have you here at Ozgrid, however, to get the most benefit from this forum please take the time to read over the forum rules.


    Thread hijacking is a violation of the forum rules.


    ALWAYS start a new thread for your questions with a link back to this thread if you think it will help.


    Robert

  • Re: Copy Data based on two criteria


    Hi Robert



    You kindly assisted my a while back with code to copy data



    I have amended the code to paste data on sheet "Recon Items" from row 10 onwards where "RS" and "'Not rec" appears on sheets STAT1 in Col AP (RS) and col V "Not REC"


    the data copies perfectly , except that when running the macro the file opens & I then click cancel



    Kindly amend code so that this does not happen




  • Re: Copy Data based on two criteria


    Quote

    except that when running the macro the file opens & I then click cancel


    Can you show me which line that is happening on as I cannot see any code that is opening a file :confused:

  • Re: Copy Data based on two criteria


    I'm have run F8 to see if I can determine line of code where I asks me to select file, but It does not do this


    As soon As I run the macro, I need to select the workbook

  • Re: Copy Data based on two criteria


    Quote

    I'm have run F8 to see if I can determine line of code where I asks me to select file, but It does not do this
    As soon As I run the macro, I need to select the workbook


    I'm afraid I can't help as I can't replicate the error and I don't understand how you can step through the macro (F8) and it works fine but not when you run it :confused:

  • Re: Copy Data based on two criteria


    Just to let you know that I run the macro on my Laptop this morning and the code runs perfectly. Not sure why I had to select the workbook from folder when running the macro on my PC at the office- must be some sort of gremlim that kept in. Anyway it is working and thanks for all your input

Participate now!

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