How can I match a random number with closest number from sequence?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

For instance, if I have the following list (my list is 255 numbers long):
A B
..7 Red
1.2 Orange
2.6 Brown
3.5 Grey
4.3 Yellow
5.5 Red Orange

and I enter 3.2 into C1, I would like for d1 to return 3.5 (the closest
number to 3.2 from sequence). That's the main thing (remember I have 255 of
these and I think excel only lets you nest 7 if's)

Once the correct match is match, I would also like to display the color it
is associated with (each of the 255 combinations has its own color)

So, after it finds the 3.5 match from the 3.2 input, I would like another
cell to display Grey.

As another example, an input of 5.0 would return 5.5 and Red Orange.

Thanks for the help.
 
Here's one way

=INDIRECT(ADDRESS(ROW(A1:A6)+MATCH(MIN(ABS(C1-A1:A6)),ABS(C1-A1:A6),0)-1,COLUMN(A1:A6)+1))

VBA Noo
 
Sorry, should of said it's an array formula so need to enter with

Ctrl + Shift + Enter

VBA Noo
 
Try this formula

=INDEX(B1:B255,MATCH(MIN(ABS(C1-A1:A255)),ABS(C1-A1:A55),0))

confirmed with CTRL+SHIFT+ENTE
 

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

Back
Top