Comparing 2 following cells (in a column) and returning value

Hi,

I'd be immensely grateful if you could help me with the following conundrum.

So I have this table in excel:

Name

Sum

a

200

b

100

 

 

a

100

 

 

a

250

b

150

 

 

a

100

 

 

a

300

 

 

a

150

b

50

 

 

a

350

b

200

 

 

I want to sum the value of each cell opposite to "a", but only if it is not followed by a cell "b"  (in bold and underlined).

In this example I should get 500.

Or vice versa, only sum the cells opposite to "a", which are followed by a "b".

Is there any (more or less simple) way it could be done?

Thank you very much in advance!

 

April 7th, 2015 3:13pm

If your data is in range A1:B18...

"a" not followed by "b"

=SUMIFS(B2:B18,A2:A18,"a",OFFSET(A2:A18,1,0),"<>b")

"a" followed by "b"

=SUMIFS(B2:B18,A2:A18,"a",OFFSET(A2:A18,1,0),"b")

Free Windows Admin Tool Kit Click here and download it now
April 7th, 2015 3:54pm

Hi psmir,

I agree with Mark18991230, his suggestion is worked.

On the other hand, we also can add a help column to get your goal. See this:

C1: =IF(OR(A2="b",A2=""),"",IF(AND(A2="a",A3="b"),1,2))

E3: =SUMIF(C:C,1,B:B)

E4: =SUMIF(C:C,2,B:B)

Hope it's helpful.

Regards,

George Zhao
TechNet Community Support

April 7th, 2015 10:51pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics