Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
163 views
in Technique[技术] by (71.8m points)

excel Formula to sum values in a column based on another value(txt) in any column

I'm trying to write an If or SumIf to calculate(sum) totals for x , y and z individually. I could use a simple sum formula but these are thousands of columns and x and y and z are populated randomly. I tried using a range by sorting colA but its a temporary solution and not what I am looking for.

I need something like:

If  COL A has 'X' then add values corresponding to X in COL B

example:

COLA   COLB  ....... colx
x      1         
x      2                
x      1
y      3
x      3
z      3
x      4                 

I tried looking up other answers for similar questions but could not find the right one that works for me.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you want to sum multiple columns based on a value in a single column you could use SUMPRODUCT like this

=SUMPRODUCT((A2:A100="x")*B2:X100)

There can't be text in the sum range, B2:X100, otherwise you get an error - if you want to allow text in that range use this version:

=SUMPRODUCT((A2:A100="x")*ISNUMBER(B2:X100),B2:X100)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...