Very hard to slove

smartguy

Well-known Member
Joined
Jul 14, 2009
Messages
778
Hello All,

Good day !!!!

I have excel in the below format.

Excel Workbook
ABCD
1NameDescStatusSpend
2raviGood boy110
3kumarAve310
4raviGood boy120
5raviGood boy230
6kumarAVE140
7sureshMED150
8subMED360
9raviGood boy270
10raviGood boy380
11raviGood boy120
Sheet1




I need sum of value based on name and status.


And also i need Descrption also.



It is possible in VBA.


Excel Workbook
FGHIJ
1NameDESCStatus 1Status 2Status 3
2raviGood boy5010080
3kumarAVE4010
4subMED60
5sureshMED50
Sheet1



Please help on that...
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
How about
Excel Workbook
ABCDEFGHIJ
1NameDescStatusSpendNameDESCStatus 1Status 2Status 3
2raviGood boy110raviGood boy5010080
3kumarAve310kumarAVE40010
4raviGood boy120subMED0060
5raviGood boy230sureshMED5000
6kumarAVE140
7sureshMED150
8subMED360
9raviGood boy270
10raviGood boy380
11raviGood boy120
Sheet1
Excel 2003
Cell Formulas
RangeFormula
H2=SUMPRODUCT(--($A$2:$A$11=$F2),--($B$2:$B$11=$G2),--($C$2:$C$11=RIGHT(H$1,1)+0),$D$2:$D$11)
<input id="gwProxy" type="hidden"><!--Session data--><input *******="jsCall();" id="jsProxy" type="hidden">
 
Upvote 0
Code:
Function sumSpend(myRange As Range, sName As String, desc As String, status As Integer) As Double
Dim temp As Integer
temp = 0
Set myRange = Range(Cells(2, 1), Cells(11, 4))
t = myRange.Rows.Count
For i = 1 To t
    If (myRange(i, 1) = sName And myRange(i, 2) = desc And myRange(i, 3) = status) Then
        temp = temp + myRange(i, 4)
    End If
Next i
sumSpend = temp
End Function

paste this code in any module and the below formula in the cell H2

=sumSpend(A2:D11,F2,G2,1)

change 1 to 2 for status 2
 
Upvote 0
If there is only one description per person then
Excel Workbook
ABCDEFGHIJ
1NameDescStatusSpendNameDESCStatus 1Status 2Status 3
2raviGood boy110raviGood boy5010080
3kumarAve310kumarAve40010
4raviGood boy120subMED0060
5raviGood boy230sureshMED5000
6kumarAVE140
7sureshMED150
8subMED360
9raviGood boy270
10raviGood boy380
11raviGood boy120
Sheet1
Excel 2003
Cell Formulas
RangeFormula
G2=INDEX($B$2:$B$11,MATCH(F2,$A$2:$A$11,0))
H2=SUMPRODUCT(--($A$2:$A$11=$F2),--($B$2:$B$11=$G2),--($C$2:$C$11=RIGHT(H$1,1)+0),$D$2:$D$11)
I2=SUMPRODUCT(--($A$2:$A$11=$F2),--($B$2:$B$11=$G2),--($C$2:$C$11=RIGHT(I$1,1)+0),$D$2:$D$11)
J2=SUMPRODUCT(--($A$2:$A$11=$F2),--($B$2:$B$11=$G2),--($C$2:$C$11=RIGHT(J$1,1)+0),$D$2:$D$11)
<input id="gwProxy" type="hidden"><!--Session data--><input *******="jsCall();" id="jsProxy" type="hidden">
 
Upvote 0
A PivotTable was suggested and I think you can get what you want with that. Here it is:

Excel Workbook
ABCDEFGHIJKL
1NameDescStatusSpendSum of SpendStatus
2raviGood boy110NameDesc123Grand Total
3kumarAve310kumarAve401050
4raviGood boy120raviGood boy5010080230
5raviGood boy230subMED6060
6kumarAVE140sureshMED5050
7sureshMED150Grand Total140100150390
8subMED360
9raviGood boy270
10raviGood boy380
11raviGood boy120
12
PivotTable
 
Upvote 0

Forum statistics

Threads
1,223,927
Messages
6,175,437
Members
452,641
Latest member
Arcaila

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top