Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 516
Default How can I match a random number with closest number from sequence?

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.

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default How can I match a random number with closest number from sequence?


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 Noob


--
VBA Noob
------------------------------------------------------------------------
VBA Noob's Profile: http://www.excelforum.com/member.php...o&userid=33833
View this thread: http://www.excelforum.com/showthread...hreadid=567664

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default How can I match a random number with closest number from sequence?


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

Ctrl + Shift + Enter

VBA Noob


--
VBA Noob
------------------------------------------------------------------------
VBA Noob's Profile: http://www.excelforum.com/member.php...o&userid=33833
View this thread: http://www.excelforum.com/showthread...hreadid=567664

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default How can I match a random number with closest number from sequence?


Try this formula

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

confirmed with CTRL+SHIFT+ENTER


--
daddylonglegs
------------------------------------------------------------------------
daddylonglegs's Profile: http://www.excelforum.com/member.php...o&userid=30486
View this thread: http://www.excelforum.com/showthread...hreadid=567664

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 516
Default How can I match a random number with closest number from seque

Thanks for the help! Both of these methods worked perfectly.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Seed numbers for random number generation, uniform distribution darebo Excel Discussion (Misc queries) 3 April 21st 23 09:02 PM
generate a random number and use if function to generate new data Dogdoc1142 Excel Worksheet Functions 4 April 26th 06 03:44 AM
Finding Closest Match andyiain Excel Worksheet Functions 1 March 15th 06 07:24 PM
How to use covar in random number generation? [email protected] Excel Discussion (Misc queries) 9 March 12th 06 07:42 PM
random number question Greegan Excel Worksheet Functions 5 October 29th 05 01:36 AM


All times are GMT +1. The time now is 08:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"