Conditionally summing data from two columns depending on their value.

A

Andy

I have two columns of data: mileage in A2:A20 and number of passengers
in B2:B20. Each row corresponds to a particular trip. I wish to sum
the number of passenger-miles for trips that have traveled within a
distance range of my discretion (the lower and upper bounds are
specified in A22:A23). How would I do this?

Thanks!
 
A

Andy

Thanks Biff for the quick solution!

(I would add that there should be >= in both instances, so as not to
double count entries.)
 
T

T. Valko

there should be >= in both instances

Then that means you want to *exclude* the upper boundary.

10...1
12...1
11...1
15...1

Boundaries:

A22 = 10
A23 = 15

=SUMIF(A2:A20,">="&A22,B2:B20)-SUMIF(A2:A20,">="&A23,B2:B20)

Returns 3

=SUMIF(A2:A20,">="&A22,B2:B20)-SUMIF(A2:A20,">"&A23,B2:B20)

Returns 4

--
Biff
Microsoft Excel MVP


Thanks Biff for the quick solution!

(I would add that there should be >= in both instances, so as not to
double count entries.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top