# Sumif Array formula with range criterion

#### TallPaul7

##### New Member
Hi All,

I'm having difficulty working out a way to solve the following issue:
I need to sum the number of vehicle trips which fall within a distance range.

eg

 1 2 3 4 5 desired outcome A Trips Distance Range Sum of trips in range B 29.4 0 5km 5.5km ???Formula??? 0 C 13.7 89.2 10 50 ---> 2.7 D 2.7 36.1 0 100 ---> (29.4+13.7+2.7)=45.8

<tbody>
</tbody>

The data I'm considering is 2100 rows deep. The range (start km and end km) can consist of any numbers (user-defined interval/series). I need the formula (or VBA code) to check whether the Distance falls within the range (eg AND(">=5","<5.5")). If the distance falls within the range then the trips need to be added to all the other trips within the range.
The outcome must be the sum of all the trips.

I have tried Sumif(B2:D2, AND(B2:D2">=5",B2:D2"<5.5"), B1:D1)
and Dsum(A1:A4, "Trips", B3:B4)
but to no avail.

I think I need an array formula (CTRL+SHIFT+ENTER) but I'm not sure which functions it needs to include and how to arrange them in such a way that the entire data set is searched (w.r.t. distance) and then the SUM of trips returned.

Any help would be much appreciated

### Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hi and welcome to Mr Excel Forum (forgot to say...)

Maybe...(Excel 2007 or higher)

=SUMIFS(A:A,B:B,">="&C2,B:B,"<="&D2)

Assumes Trips in column A, Distance in column B and so on

M.

Last edited:
Hi Marcelo,

Thank you for the friendly welcome. I often read MrExcel posts but this time I just had to ask a Q myself. Thank you for the suggestion. It works perfectly. Very simple and efficient too (I've never used SUMIFS before).
Ciao for now

Hi Marcelo,

Thank you for the friendly welcome. I often read MrExcel posts but this time I just had to ask a Q myself. Thank you for the suggestion. It works perfectly. Very simple and efficient too (I've never used SUMIFS before).
Ciao for now

You are very welcome and thanks for the feedback!

M.

Replies
5
Views
246
Replies
0
Views
545
Replies
12
Views
934
Replies
3
Views
896
Replies
6
Views
131

1,196,429
Messages
6,015,207
Members
441,882
Latest member
rcgyuk

### 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.

### Which adblocker are you using?

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

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