VBA code to pick data based on multiple conditions

  • Hello guys,


    I've been struggling to write this for days macro and I have finally decided to ask for your help.


    Here's what I have:


    Sheet1 - Job IDs, Assignees and Tasks as headers


    A1 - IDs

    B1 - Assignees

    C1 - Tasks

    *Rest of the columns are something i've tried which did not work out.


    There are different no. of Jobs in the data and each job has 2 tasks only. The tasks (task1 and task2) of each job are done by either 2 assignees separately or done by the same assignee (for some jobs).


    What I am trying to achieve:


    - I want to filter data in such a way that the macro should pick only five task1's and task2's of each assignee.

    - But ideally, when a task2 of a job is picked, task 1 of the same job should also be picked keeping in mind that the assignee that did that task did not have more than 5 task1;s (or) task2's picked.

    - My idea is, the macro should be able to ideally keep a log or delete data no. of tasks of a particular assignee once they reach the threshold of 5.

    - To put it in simple terms, the no. of jobs picked do not matter, but both task 1 and 2 of any Job should be picked and each assignee should equally have 5 task1 and task2's.


    I had multiple attempts but I have failed miserably. I would be really grateful if someone helps me out.


    Thank you,

    Tirumal


    *Please find the attached sample workbook.