Find nearest and exclude member of array

shvraka

New Member
Joined
Dec 3, 2009
Messages
20
Hello!
I need help with {=INDEX(MATCH.....} or something like that formula.

I would like to make a formula that finds the nearest value, of a given cell, in an array of data, and exclude that array member in folowing cell.
Here is an example:
1596710748168.png



Thank you in advance!
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Try:

Book1
ABC
1array1array2formula for nearest in array1
221514
38 
4942
51218
625 
743 
8772525
914 
Sheet2
Cell Formulas
RangeFormula
C2:C9C2=IF(B2="","",INDEX($A$2:$A$9,MATCH(MIN(ABS($A$2:$A$9+COUNTIF($C$1:$C1,$A$2:$A$9)*9^9-B2)),ABS($A$2:$A$9+COUNTIF($C$1:$C1,$A$2:$A$9)*9^9-B2),0)))
Press CTRL+SHIFT+ENTER to enter array formulas.


Note that this formula works from the top down. So the C4 cell calculates 2 as being closest, then the C5 cell excludes 2 as an option and picks 8 instead. Your example had the C5 value picked first. If the values in column B are entered manually in a random order, then you'd probably need to create a Worksheet Change event to perform the job of filling the C column.
 
Upvote 0

Forum statistics

Threads
1,214,838
Messages
6,121,885
Members
449,057
Latest member
Moo4247

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top