ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   conditional sum? (https://www.excelbanter.com/excel-discussion-misc-queries/169920-conditional-sum.html)

Lamb Chop

conditional sum?
 
A1= Apple B1 =12
A2= Orange B2 = 52
A3 = Orange B3= 51
A4=Banana B4=53
A5 =grape B5=43
A6=grape B6 = 6
A7=grape B7 = 88



In the C column I'd like to add the number from B column if A column the
same.

The end result will look like:

C1= 12
C2 = 52+ 51 (as A2 and A3 both are orange so add B2 and B3
together)
C3= "" (leave it blank as C2 already did the job)
C4=53
C5 = 43+6 +88 (as A5, A6 and A7 are all grape, so add B5 to B7
together)
C6 = ""
C7 =""


so the outcome will look like this:

A1= Apple B1 =12 C1=12
A2= Orange B2 = 52 C2=103
A3 = Orange B3= 51 C3=
A4=Banana B4=53 C4=53
A5 =grape B5=43 C5=137
A6=grape B6 = 6 C6=
A7=grape B7 = 88 C7=


Any suggesion?

Thanks






Sandy Mann

conditional sum?
 
Try:

=IF(COUNTIF($A$1:A1,A1)=1,SUMIF($A$1:$A$7,A1,$B$1: $B$7),"")

and drag down on the fill handle

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


Replace @mailinator.com with @tiscali.co.uk


"Lamb Chop" wrote in message
...
A1= Apple B1 =12
A2= Orange B2 = 52
A3 = Orange B3= 51
A4=Banana B4=53
A5 =grape B5=43
A6=grape B6 = 6
A7=grape B7 = 88



In the C column I'd like to add the number from B column if A column the
same.

The end result will look like:

C1= 12
C2 = 52+ 51 (as A2 and A3 both are orange so add B2 and B3
together)
C3= "" (leave it blank as C2 already did the
job)
C4=53
C5 = 43+6 +88 (as A5, A6 and A7 are all grape, so add B5 to B7
together)
C6 = ""
C7 =""


so the outcome will look like this:

A1= Apple B1 =12 C1=12
A2= Orange B2 = 52 C2=103
A3 = Orange B3= 51 C3=
A4=Banana B4=53 C4=53
A5 =grape B5=43 C5=137
A6=grape B6 = 6 C6=
A7=grape B7 = 88 C7=


Any suggesion?

Thanks









Max

conditional sum?
 
One way
In C1: =IF(A1="","",SUMIF(A:A,A1,B:B))
In D1: =IF(COUNTIF($A$1:A1,A1)1,"",C1)
Select C1:D1, copy down. Hide away col C.
Col D returns the required results.
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Lamb Chop" wrote in message
...
A1= Apple B1 =12
A2= Orange B2 = 52
A3 = Orange B3= 51
A4=Banana B4=53
A5 =grape B5=43
A6=grape B6 = 6
A7=grape B7 = 88



In the C column I'd like to add the number from B column if A column the
same.

The end result will look like:

C1= 12
C2 = 52+ 51 (as A2 and A3 both are orange so add B2 and B3
together)
C3= "" (leave it blank as C2 already did the
job)
C4=53
C5 = 43+6 +88 (as A5, A6 and A7 are all grape, so add B5 to B7
together)
C6 = ""
C7 =""


so the outcome will look like this:

A1= Apple B1 =12 C1=12
A2= Orange B2 = 52 C2=103
A3 = Orange B3= 51 C3=
A4=Banana B4=53 C4=53
A5 =grape B5=43 C5=137
A6=grape B6 = 6 C6=
A7=grape B7 = 88 C7=


Any suggesion?

Thanks









All times are GMT +1. The time now is 08:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com