kashif.special2005
Active Member
- Joined
- Oct 26, 2009
- Messages
- 443
Hi,
I have a sample data as below, original data is around 90 thousand.
Please Note:- That in the below sample data the value in the column "Approval Status" is show "Approved", but this is not the case it can be other values as well for example like "Rejected" or "Submitted" etc.,
Sample Data:-
[TABLE="width: 413"]
<colgroup><col><col><col><col></colgroup><tbody>[TR]
[TD]ID[/TD]
[TD]Category[/TD]
[TD]Number of Hours[/TD]
[TD]Approval Status[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Training[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Revenue[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Training[/TD]
[TD]4[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Business Support[/TD]
[TD]4[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Business Support[/TD]
[TD]4[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Business Support[/TD]
[TD]4[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Sales Sales Support[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Revenue[/TD]
[TD]4[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Sales Sales Support[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Sales Sales Support[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Sales Sales Support[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Sales Sales Support[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Sales Sales Support[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Revenue[/TD]
[TD]4[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Absence[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Revenue[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Revenue[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Revenue[/TD]
[TD]4[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Business Support[/TD]
[TD]4[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Business Support[/TD]
[TD]4[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Revenue[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Revenue[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Revenue[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Revenue[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Revenue[/TD]
[TD]4[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Standard Hours[/TD]
[TD]0[/TD]
[TD]Approved
[/TD]
[/TR]
</tbody>[/TABLE]
And I want to create the output as below for each unique ID's, below is the sample for 1 ID's
Desired Output.
[TABLE="width: 581"]
<colgroup><col><col><col><col><col><col><col></colgroup><tbody>[TR]
[TD]ID[/TD]
[TD]CPAR[/TD]
[TD]PPAR[/TD]
[TD]HBAR[/TD]
[TD]ODAR[/TD]
[TD]CPAR + PPAR[/TD]
[TD]HBAR:Absence[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD="align: right"]72[/TD]
[TD="align: right"]48[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]12[/TD]
[TD="align: right"]120[/TD]
[TD="align: right"]8[/TD]
[/TR]
</tbody>[/TABLE]
Conditions For Calculating the columns "CPA, PPAR, HBAR, ODAR, CPAR + PPAR And HBAR:Absence"
Condition(1) - CPAR (Column):- Calculating Condition
if column "Approval Status=Approved" and column "Category=Revenue, or Category=Cost
Recovery" then take the sum of column "Number of Hours" and put the value in the column
B against the ID.
Condition(2) - PPAR (Column):- Calculating Condition
if column "Approval Status=Approved" and column "Category=Sales Sales Support" then
take the sum of column "Number of Hours" and put the value in the column C against the ID.
Condition(3) - ODAR (Column):- Calculating Condition
if column "Approval Status=Approved" and column "Category=Training" then take the sum of
column "Number of Hours" and put the value in the column E against the ID.
Condition(4) - HBAR (Column):- Calculating Condition
if Above conditions (1, 2 And 3) are not meet and column "Approval Status<>Approved" and
column "Category<>Absence" then take the sum of column "Number of Hours" and put the
value in the column D against the D.
Condition(5) - HBAR:Absence (Column):- Calculating Condition
if Above all three condition (1, 2 And 3) are not meet and column "Approval
Status=Approved" and column "Category=Absence" then take the sum of column "Number of
Hours" and put the value in the column G against the ID.
Condition(6) - CPAR + PPAR (Column):- Calculating Condition
Simply put the sum of column B (CPAR) + Column C (PPAR)
I don't have any idea how can I achieve desired result, my head is spinning to think about that.
Kindly request to all of excel vba champs, please help me to achieve this task.
Many thanks in advance
Thanks
Kashif
I have a sample data as below, original data is around 90 thousand.
Please Note:- That in the below sample data the value in the column "Approval Status" is show "Approved", but this is not the case it can be other values as well for example like "Rejected" or "Submitted" etc.,
Sample Data:-
[TABLE="width: 413"]
<colgroup><col><col><col><col></colgroup><tbody>[TR]
[TD]ID[/TD]
[TD]Category[/TD]
[TD]Number of Hours[/TD]
[TD]Approval Status[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Training[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Revenue[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Training[/TD]
[TD]4[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Business Support[/TD]
[TD]4[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Business Support[/TD]
[TD]4[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Business Support[/TD]
[TD]4[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Sales Sales Support[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Revenue[/TD]
[TD]4[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Sales Sales Support[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Sales Sales Support[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Sales Sales Support[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Sales Sales Support[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Sales Sales Support[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Revenue[/TD]
[TD]4[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Absence[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Revenue[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Revenue[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Revenue[/TD]
[TD]4[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Business Support[/TD]
[TD]4[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Business Support[/TD]
[TD]4[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Revenue[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Revenue[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Revenue[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Revenue[/TD]
[TD]8[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Revenue[/TD]
[TD]4[/TD]
[TD]Approved[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD]Standard Hours[/TD]
[TD]0[/TD]
[TD]Approved
[/TD]
[/TR]
</tbody>[/TABLE]
And I want to create the output as below for each unique ID's, below is the sample for 1 ID's
Desired Output.
[TABLE="width: 581"]
<colgroup><col><col><col><col><col><col><col></colgroup><tbody>[TR]
[TD]ID[/TD]
[TD]CPAR[/TD]
[TD]PPAR[/TD]
[TD]HBAR[/TD]
[TD]ODAR[/TD]
[TD]CPAR + PPAR[/TD]
[TD]HBAR:Absence[/TD]
[/TR]
[TR]
[TD]69033154[/TD]
[TD="align: right"]72[/TD]
[TD="align: right"]48[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]12[/TD]
[TD="align: right"]120[/TD]
[TD="align: right"]8[/TD]
[/TR]
</tbody>[/TABLE]
Conditions For Calculating the columns "CPA, PPAR, HBAR, ODAR, CPAR + PPAR And HBAR:Absence"
Condition(1) - CPAR (Column):- Calculating Condition
if column "Approval Status=Approved" and column "Category=Revenue, or Category=Cost
Recovery" then take the sum of column "Number of Hours" and put the value in the column
B against the ID.
Condition(2) - PPAR (Column):- Calculating Condition
if column "Approval Status=Approved" and column "Category=Sales Sales Support" then
take the sum of column "Number of Hours" and put the value in the column C against the ID.
Condition(3) - ODAR (Column):- Calculating Condition
if column "Approval Status=Approved" and column "Category=Training" then take the sum of
column "Number of Hours" and put the value in the column E against the ID.
Condition(4) - HBAR (Column):- Calculating Condition
if Above conditions (1, 2 And 3) are not meet and column "Approval Status<>Approved" and
column "Category<>Absence" then take the sum of column "Number of Hours" and put the
value in the column D against the D.
Condition(5) - HBAR:Absence (Column):- Calculating Condition
if Above all three condition (1, 2 And 3) are not meet and column "Approval
Status=Approved" and column "Category=Absence" then take the sum of column "Number of
Hours" and put the value in the column G against the ID.
Condition(6) - CPAR + PPAR (Column):- Calculating Condition
Simply put the sum of column B (CPAR) + Column C (PPAR)
I don't have any idea how can I achieve desired result, my head is spinning to think about that.
Kindly request to all of excel vba champs, please help me to achieve this task.
Many thanks in advance
Thanks
Kashif