View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld[_2_] Ron Rosenfeld[_2_] is offline
external usenet poster
 
Posts: 1,045
Default Nearest one or two or three numbers in a row of data

On Sat, 16 Jun 2012 11:42:24 +0000, tikrit wrote:


Hi Everyone,

I have a problem today. I tried in different ways but could not solve
it.

Lest's say I have the following row of Data:

61 49 55 45 48 69 79 51

I need a code (Excel formula) that find the closest two or three numbers
to 50 but lower than 50 (which in this case are 49 48 and 45)

I will then add them to each other and put the result in a single cell

Notes : the data must be in Row. Mine is Excel 2010.

Thanks in Advance for your help


This formula must be **array-entered**:

=SUM(LARGE(IF(Rng<=50,Rng),{1,2,3}))

Rng Refers To the cells containing your values.
----------------------------------------

To **array-enter** a formula, after entering
the formula into the cell or formula bar, hold down
<ctrl<shift while hitting <enter. If you did this
correctly, Excel will place braces {...} around the formula.