Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
RBW RBW is offline
external usenet poster
 
Posts: 5
Default Compare number to range; find highest positive difference

I need to compare the value in a cell to a range of values, and select the
value in the range that has the smallest positive difference. If the index
cell is 4, and the range has 1,2,3 and 9, I need the range to pick 9. I've
tried to use =min(index no. - range), but that doesn't seem to work; vlookup
doesn't seem to work, either.

Grateful for your thoughts.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default Compare number to range; find highest positive difference

Try this array formula** :

A1 = base number
C1:C4 = range of numbers

=INDEX(C1:C4,MATCH(TRUE,C1:C4-A1=MIN(IF(C1:C4-A1=0,C1:C4-A1)),0))

** array formulas need to be entered using the key combination of
CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the SHIFT
key then hit ENTER.


--
Biff
Microsoft Excel MVP


"RBW" wrote in message
...
I need to compare the value in a cell to a range of values, and select the
value in the range that has the smallest positive difference. If the
index
cell is 4, and the range has 1,2,3 and 9, I need the range to pick 9.
I've
tried to use =min(index no. - range), but that doesn't seem to work;
vlookup
doesn't seem to work, either.

Grateful for your thoughts.



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
RBW RBW is offline
external usenet poster
 
Posts: 5
Default Compare number to range; find highest positive difference

Biff-

Many thanks- that works perfectly. Impressive coding!

RBW

"T. Valko" wrote:

Try this array formula** :

A1 = base number
C1:C4 = range of numbers

=INDEX(C1:C4,MATCH(TRUE,C1:C4-A1=MIN(IF(C1:C4-A1=0,C1:C4-A1)),0))

** array formulas need to be entered using the key combination of
CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the SHIFT
key then hit ENTER.


--
Biff
Microsoft Excel MVP


"RBW" wrote in message
...
I need to compare the value in a cell to a range of values, and select the
value in the range that has the smallest positive difference. If the
index
cell is 4, and the range has 1,2,3 and 9, I need the range to pick 9.
I've
tried to use =min(index no. - range), but that doesn't seem to work;
vlookup
doesn't seem to work, either.

Grateful for your thoughts.




  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default Compare number to range; find highest positive difference

You're welcome. Thanks for the feedback!

--
Biff
Microsoft Excel MVP


"RBW" wrote in message
...
Biff-

Many thanks- that works perfectly. Impressive coding!

RBW

"T. Valko" wrote:

Try this array formula** :

A1 = base number
C1:C4 = range of numbers

=INDEX(C1:C4,MATCH(TRUE,C1:C4-A1=MIN(IF(C1:C4-A1=0,C1:C4-A1)),0))

** array formulas need to be entered using the key combination of
CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the
SHIFT
key then hit ENTER.


--
Biff
Microsoft Excel MVP


"RBW" wrote in message
...
I need to compare the value in a cell to a range of values, and select
the
value in the range that has the smallest positive difference. If the
index
cell is 4, and the range has 1,2,3 and 9, I need the range to pick 9.
I've
tried to use =min(index no. - range), but that doesn't seem to work;
vlookup
doesn't seem to work, either.

Grateful for your thoughts.






  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 947
Default Compare number to range; find highest positive difference



Not sure, but this array formula might be another option.
It assumes your input data is in the range 1-9.

=MIN(IF(C1:C4A1,C1:C4))

Note that if the input is 3, it rounds up to 9.
This is because you said "the smallest positive difference."
A returned value of 3 is a zero difference is not what you asked.
Perhaps you meant non-negative (0 or better).
- - -
HTH :)
Dana DeLouis


RBW wrote:
Biff-

Many thanks- that works perfectly. Impressive coding!

RBW

"T. Valko" wrote:

Try this array formula** :

A1 = base number
C1:C4 = range of numbers

=INDEX(C1:C4,MATCH(TRUE,C1:C4-A1=MIN(IF(C1:C4-A1=0,C1:C4-A1)),0))

** array formulas need to be entered using the key combination of
CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the SHIFT
key then hit ENTER.


--
Biff
Microsoft Excel MVP


"RBW" wrote in message
...
I need to compare the value in a cell to a range of values, and select the
value in the range that has the smallest positive difference. If the
index
cell is 4, and the range has 1,2,3 and 9, I need the range to pick 9.
I've
tried to use =min(index no. - range), but that doesn't seem to work;
vlookup
doesn't seem to work, either.

Grateful for your thoughts.





  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default Compare number to range; find highest positive difference

Wow!

You think I made that more complicated than need be? <g

--
Biff
Microsoft Excel MVP


"Dana DeLouis" wrote in message
...


Not sure, but this array formula might be another option.
It assumes your input data is in the range 1-9.

=MIN(IF(C1:C4A1,C1:C4))

Note that if the input is 3, it rounds up to 9.
This is because you said "the smallest positive difference."
A returned value of 3 is a zero difference is not what you asked. Perhaps
you meant non-negative (0 or better).
- - -
HTH :)
Dana DeLouis


RBW wrote:
Biff-

Many thanks- that works perfectly. Impressive coding!

RBW

"T. Valko" wrote:

Try this array formula** :

A1 = base number
C1:C4 = range of numbers

=INDEX(C1:C4,MATCH(TRUE,C1:C4-A1=MIN(IF(C1:C4-A1=0,C1:C4-A1)),0))

** array formulas need to be entered using the key combination of
CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the
SHIFT key then hit ENTER.


--
Biff
Microsoft Excel MVP


"RBW" wrote in message
...
I need to compare the value in a cell to a range of values, and select
the
value in the range that has the smallest positive difference. If the
index
cell is 4, and the range has 1,2,3 and 9, I need the range to pick 9.
I've
tried to use =min(index no. - range), but that doesn't seem to work;
vlookup
doesn't seem to work, either.

Grateful for your thoughts.




  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
RBW RBW is offline
external usenet poster
 
Posts: 5
Default Compare number to range; find highest positive difference

Dana-

Appreciate the thought. The actual application is to compare the date an
expense was incurred (the index cell) against the range of dates of invoices
sent to a client (hence the need for only a positive difference- you can't go
back and add to a past invoice :) ). I suppose an expense could be
incurred and billed on the same day (the "0" outcome), but would guess it's
unlikely, so a positive number is probably what the formula needs to find.

A nice enhancement, which I think I can do using the =IF function, would be
to show, for expense dates newer than any invoice, a message along the lines
of, "Not yet billed" or something like that.

FWIW, I'm looked at as understanding Excel pretty well, but every time I
come here, I realize how little I know compared to all of you. Really
appreciate everyone's time in thinking through issues like this.

"Dana DeLouis" wrote:



Not sure, but this array formula might be another option.
It assumes your input data is in the range 1-9.

=MIN(IF(C1:C4A1,C1:C4))

Note that if the input is 3, it rounds up to 9.
This is because you said "the smallest positive difference."
A returned value of 3 is a zero difference is not what you asked.
Perhaps you meant non-negative (0 or better).
- - -
HTH :)
Dana DeLouis


RBW wrote:
Biff-

Many thanks- that works perfectly. Impressive coding!

RBW

"T. Valko" wrote:

Try this array formula** :

A1 = base number
C1:C4 = range of numbers

=INDEX(C1:C4,MATCH(TRUE,C1:C4-A1=MIN(IF(C1:C4-A1=0,C1:C4-A1)),0))

** array formulas need to be entered using the key combination of
CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the SHIFT
key then hit ENTER.


--
Biff
Microsoft Excel MVP


"RBW" wrote in message
...
I need to compare the value in a cell to a range of values, and select the
value in the range that has the smallest positive difference. If the
index
cell is 4, and the range has 1,2,3 and 9, I need the range to pick 9.
I've
tried to use =min(index no. - range), but that doesn't seem to work;
vlookup
doesn't seem to work, either.

Grateful for your thoughts.



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
Compare two columns and find the difference between the two column kpk Excel Discussion (Misc queries) 2 April 3rd 23 01:30 PM
Find closest match and return next highest number in range x6v87qe Excel Discussion (Misc queries) 4 June 18th 08 01:58 PM
An add-in that allows you to find the highest prime in a number [email protected] Excel Discussion (Misc queries) 1 April 12th 06 01:06 AM
Find Median of Positive numbers only in Range MichaelC Excel Worksheet Functions 4 June 24th 05 03:06 AM
How do I compare 2 worksheets, 1 old, 1 updated to find difference alienstew Excel Discussion (Misc queries) 1 January 31st 05 02:01 PM


All times are GMT +1. The time now is 06:12 AM.

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

About Us

"It's about Microsoft Excel"