Inverse For Next loop with two conditions

  • Hi experts,


    The code below groups data by agent name and the total revenue generated by each agent. However I need to include a date column in this table and use this column in my group condition as well, so as result and should have the table 2:


    Could someone help me to include the second condition in my inverse loop.




    [TABLE="border: 1, cellpadding: 1, width: 500"]

    [tr]


    [td]

    Table 1
    Before running the macro: [TABLE="border: 0, cellpadding: 0, cellspacing: 0, width: 319"]

    [tr]


    [td]

    Name

    [/td]


    [td]

    Phone

    [/td]


    [td]

    Sales/Call

    [/td]


    [/tr]


    [tr]


    [td]

    Guy

    [/td]


    [td]

    1-565-498-6512

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    John

    [/td]


    [td]

    1-565-498-6513

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Mary

    [/td]


    [td]

    1-565-498-6514

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Ted

    [/td]


    [td]

    1-565-498-6515

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Guy

    [/td]


    [td]

    1-565-498-6512

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    John

    [/td]


    [td]

    1-565-498-6513

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Mary

    [/td]


    [td]

    1-565-498-6514

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Ted

    [/td]


    [td]

    1-565-498-6515

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Guy

    [/td]


    [td]

    1-565-498-6512

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    John

    [/td]


    [td]

    1-565-498-6513

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Mary

    [/td]


    [td]

    1-565-498-6514

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Ted

    [/td]


    [td]

    1-565-498-6515

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Guy

    [/td]


    [td]

    1-565-498-6512

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    John

    [/td]


    [td]

    1-565-498-6513

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Mary

    [/td]


    [td]

    1-565-498-6514

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Ted

    [/td]


    [td]

    1-565-498-6515

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [/TABLE]

    [/td]


    [td]

    [TABLE="border: 1, cellpadding: 0, cellspacing: 0"]

    [tr]


    [td]

    Table 1
    After running the macro: [TABLE="border: 0, cellpadding: 0, cellspacing: 0, width: 319"]

    [tr]


    [td]

    Name

    [/td]


    [td]

    Phone

    [/td]


    [td]

    Sales/Call

    [/td]


    [/tr]


    [tr]


    [td]

    Guy

    [/td]


    [td]

    1-565-498-6512

    [/td]


    [td]

    $4.00

    [/td]


    [/tr]


    [tr]


    [td]

    John

    [/td]


    [td]

    1-565-498-6513

    [/td]


    [td]

    $4.00

    [/td]


    [/tr]


    [tr]


    [td]

    Mary

    [/td]


    [td]

    1-565-498-6514

    [/td]


    [td]

    $4.00

    [/td]


    [/tr]


    [tr]


    [td]

    Ted

    [/td]


    [td]

    1-565-498-6515

    [/td]


    [td]

    $4.00

    [/td]


    [/tr]


    [/TABLE]

    [/td]


    [/tr]


    [/TABLE]

    [/td]


    [/tr]


    [tr]


    [td]

    Table 2
    Before running the macro: [TABLE="border: 0, cellpadding: 0, cellspacing: 0, width: 397"]

    [tr]


    [td]

    Name

    [/td]


    [td]

    Date

    [/td]


    [td]

    Phone

    [/td]


    [td]

    Sales/Call

    [/td]


    [/tr]


    [tr]


    [td]

    Guy

    [/td]


    [td]

    7/05/2018

    [/td]


    [td]

    1-565-498-6512

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    John

    [/td]


    [td]

    7/05/2018

    [/td]


    [td]

    1-565-498-6513

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Mary

    [/td]


    [td]

    7/05/2018

    [/td]


    [td]

    1-565-498-6514

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Ted

    [/td]


    [td]

    7/05/2018

    [/td]


    [td]

    1-565-498-6515

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Guy

    [/td]


    [td]

    7/05/2018

    [/td]


    [td]

    1-565-498-6512

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    John

    [/td]


    [td]

    7/05/2018

    [/td]


    [td]

    1-565-498-6513

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Mary

    [/td]


    [td]

    7/05/2018

    [/td]


    [td]

    1-565-498-6514

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Ted

    [/td]


    [td]

    7/05/2018

    [/td]


    [td]

    1-565-498-6515

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Guy

    [/td]


    [td]

    8/05/2018

    [/td]


    [td]

    1-565-498-6512

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    John

    [/td]


    [td]

    8/05/2018

    [/td]


    [td]

    1-565-498-6513

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Mary

    [/td]


    [td]

    8/05/2018

    [/td]


    [td]

    1-565-498-6514

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Ted

    [/td]


    [td]

    8/05/2018

    [/td]


    [td]

    1-565-498-6515

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Guy

    [/td]


    [td]

    9/05/2018

    [/td]


    [td]

    1-565-498-6512

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    John

    [/td]


    [td]

    9/05/2018

    [/td]


    [td]

    1-565-498-6513

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Mary

    [/td]


    [td]

    9/05/2018

    [/td]


    [td]

    1-565-498-6514

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Ted

    [/td]


    [td]

    9/05/2018

    [/td]


    [td]

    1-565-498-6515

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [/TABLE]

    [/td]


    [td]

    Table 2
    After running the macro: [TABLE="border: 0, cellpadding: 0, cellspacing: 0, width: 345"]

    [tr]


    [td]

    Name

    [/td]


    [td]

    Date

    [/td]


    [td]

    Phone

    [/td]


    [td]

    Sales/Call

    [/td]


    [/tr]


    [tr]


    [td]

    Guy

    [/td]


    [td]

    7/05/2018

    [/td]


    [td]

    1-565-498-6512

    [/td]


    [td]

    $2.00

    [/td]


    [/tr]


    [tr]


    [td]

    John

    [/td]


    [td]

    7/05/2018

    [/td]


    [td]

    1-565-498-6513

    [/td]


    [td]

    $2.00

    [/td]


    [/tr]


    [tr]


    [td]

    Mary

    [/td]


    [td]

    7/05/2018

    [/td]


    [td]

    1-565-498-6514

    [/td]


    [td]

    $2.00

    [/td]


    [/tr]


    [tr]


    [td]

    Ted

    [/td]


    [td]

    7/05/2018

    [/td]


    [td]

    1-565-498-6515

    [/td]


    [td]

    $2.00

    [/td]


    [/tr]


    [tr]


    [td]

    Guy

    [/td]


    [td]

    8/05/2018

    [/td]


    [td]

    1-565-498-6512

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    John

    [/td]


    [td]

    8/05/2018

    [/td]


    [td]

    1-565-498-6513

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Mary

    [/td]


    [td]

    8/05/2018

    [/td]


    [td]

    1-565-498-6514

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Ted

    [/td]


    [td]

    8/05/2018

    [/td]


    [td]

    1-565-498-6515

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Guy

    [/td]


    [td]

    9/05/2018

    [/td]


    [td]

    1-565-498-6512

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    John

    [/td]


    [td]

    9/05/2018

    [/td]


    [td]

    1-565-498-6513

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Mary

    [/td]


    [td]

    9/05/2018

    [/td]


    [td]

    1-565-498-6514

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [tr]


    [td]

    Ted

    [/td]


    [td]

    9/05/2018

    [/td]


    [td]

    1-565-498-6515

    [/td]


    [td]

    $1.00

    [/td]


    [/tr]


    [/TABLE]

    [/td]


    [/tr]


    [/TABLE]
    Cheers,
    Gilly

  • Try this, assumes that the Sales/Call column in you actual sheet is formatted as Currency and value in each row is 1.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • This will be much faster, especially if you have a large amount of data.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • You're welcome.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

Participate now!

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