# Excel - sum of what range is closest to 50%

I have % values in cells A1:A60 (sum = 100%). I want to find out what range (starting from A1 downwards) will get me closest to 50%.

For example if Sum(A1:A32)=0.482 and Sum(A1:A33)=0.52, I would want it to return range A1:A32 (in actual fact, I'd want it to return the value 32 that represents the bottom of this range).

This formula needs to be repeatable over many such 1-dimensional ranges, so a 'solve' method isn't really what I'm after. I'm hoping for a tidy formula in a single cell for each range.

Many thanks!

P.S. Please assume the distribution of data within each range is random

Best I can do is this array formula**:

=MATCH(TRUE,ABS(B1-SUBTOTAL(9,OFFSET(A1,,,ROW(A1:A60)-MIN(ROW(A1:A60))+1,)))=MIN(ABS(B1-SUBTOTAL(9,OFFSET(A1,,,ROW(A1:A60)-MIN(ROW(A1:A60))+1,)))),0)

where B1 contains your desired threshold, e.g. 0.5.

Regards

**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

### Xpath consuming to much CPU on Postgresql

I have a problem with a production software eating all cpu from db server.

### Use tnsnames.ora in Oracle SQL Developer

I am evaluating Oracle SQL Developer.