Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 34
Default Searching for low and high number

I have the following example

A column with number of days:

days
3
7
31
61
91
181
271
365

Now i have a certain formula which returns to me a number of days -
for example 21. 21 belongs in between 7 and 31 in the days column. I
am looking for a formulas that would return this high and low number
of the interval in which my number belongs to:

- for 21, the solution should be 7 and 32,
- for 183, the solution should be 181 and 271
- and if the number equals one of the numbers in the column the
solution should be the exact number if i have 31 the solution should
be 31

is there a way to do this. thanx for your help!
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 34
Default Searching for low and high number



sorry made a slight mistake above:
- for 21, the solution should be 7 and 31 not 32
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Searching for low and high number

Hi,

I assume if there is an exact match you want that. with your lookup value in
D1

For the lower number

=LOOKUP(D1,A1:A8)

For the higher

=MIN(IF(A1:A8=D1,A1:A8))

The second formula is an array.
'This is an array formula which must be entered with CTRL+Shift+Enter and NOT
'just enter. If you do it correctly then Excel will put curly brackets around
'the formula{}. You can't type these yourself. If you Edit the ranges
'then you must re-enter as An array

Mike

"Mortir" wrote:



sorry made a slight mistake above:
- for 21, the solution should be 7 and 31 not 32

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 694
Default Searching for low and high number

Hi Mortir
Did you try MAX and MIN eg: =MAX(A2:A3) same for MIN.
Regards
John
"Mortir" wrote in message
...
I have the following example

A column with number of days:

days
3
7
31
61
91
181
271
365

Now i have a certain formula which returns to me a number of days -
for example 21. 21 belongs in between 7 and 31 in the days column. I
am looking for a formulas that would return this high and low number
of the interval in which my number belongs to:

- for 21, the solution should be 7 and 32,
- for 183, the solution should be 181 and 271
- and if the number equals one of the numbers in the column the
solution should be the exact number if i have 31 the solution should
be 31

is there a way to do this. thanx for your help!


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 913
Default Searching for low and high number

On Sun, 25 Jan 2009 09:55:47 -0800 (PST), Mortir
wrote:

I have the following example

A column with number of days:

days
3
7
31
61
91
181
271
365

Now i have a certain formula which returns to me a number of days -
for example 21. 21 belongs in between 7 and 31 in the days column. I
am looking for a formulas that would return this high and low number
of the interval in which my number belongs to:

- for 21, the solution should be 7 and 32,
- for 183, the solution should be 181 and 271
- and if the number equals one of the numbers in the column the
solution should be the exact number if i have 31 the solution should
be 31

is there a way to do this. thanx for your help!



If your table of days are in A2:A9 and your number is in B1 you may
try this formula (all in one line):

=IF(ISERROR(VLOOKUP(B1,A2:A9,1,FALSE)),VLOOKUP(B1, A2:A9,1,TRUE)&" and
"&INDEX(A2:A9,MATCH(B1,A2:A9,1)+1),B1)

Change the range A2:A9 to fit your days table.

Hope this helps / Lars-Åke




  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 747
Default Searching for low and high number

for low number
=INDEX(A1:A8,MATCH(B1,A1:A8,1),0)

for high number
=INDEX(A1:A8,MATCH(B1,A1:A8,1)+1,0)

On Jan 25, 10:55*pm, Mortir wrote:
I have the following example

A column with number of days:

days
3
7
31
61
91
181
271
365

Now i have a certain formula which returns to me a number of days *-
for example 21. 21 belongs in between 7 and 31 in the days column. I
am looking for a formulas that would return this high and low number
of the interval in which my number belongs to:

- for 21, the solution should be 7 and 32,
- for 183, the solution should be 181 and 271
- and if the number equals one of the numbers in the column the
solution should be the exact number if i have 31 the solution should
be 31

is there a way to do this. thanx for your help!


  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 34
Default Searching for low and high number

On Jan 25, 7:35*pm, muddan madhu wrote:
for low number
=INDEX(A1:A8,MATCH(B1,A1:A8,1),0)

for high number
=INDEX(A1:A8,MATCH(B1,A1:A8,1)+1,0)

On Jan 25, 10:55*pm, Mortir wrote:

I have the following example


A column with number of days:


days
3
7
31
61
91
181
271
365


Now i have a certain formula which returns to me a number of days *-
for example 21. 21 belongs in between 7 and 31 in the days column. I
am looking for a formulas that would return this high and low number
of the interval in which my number belongs to:


- for 21, the solution should be 7 and 32,
- for 183, the solution should be 181 and 271
- and if the number equals one of the numbers in the column the
solution should be the exact number if i have 31 the solution should
be 31


is there a way to do this. thanx for your help!


tnx guys. realy appreciate your help!!!!
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,346
Default Searching for low and high number

Hi,

It would be nice to use the BETWEEN function, ha! but there isn't one in
Excel.

You can make a minute simplification to the previous suggestion
=MIN(IF(A1:A8D1,A1:A8))
since by definition you don't want the min and max to be the same. This
assumes that your first formula is in D1

Of course these suggestions assume that the data is in Ascending order and
my simplification assumes that there are no duplicates.

If the numbers are not in order:
Use the following array to get the lower number and
=MAX(IF(A1:A8<=C1,A1:A8))
and
=MIN(IF(A1:A8D1,A1:A8))
to get the upper number

These two formulas assume the number you want to check for is in C1 and the
first formula is entered in D1

These must be entered by pressing Shift+Ctrl+Enter

--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"Mortir" wrote:



sorry made a slight mistake above:
- for 21, the solution should be 7 and 31 not 32

  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,346
Default Searching for low and high number

Hi,

Take out my = sign in
=MAX(IF(A1:A8<=C1,A1:A8))

--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"Shane Devenshire" wrote:

Hi,

It would be nice to use the BETWEEN function, ha! but there isn't one in
Excel.

You can make a minute simplification to the previous suggestion
=MIN(IF(A1:A8D1,A1:A8))
since by definition you don't want the min and max to be the same. This
assumes that your first formula is in D1

Of course these suggestions assume that the data is in Ascending order and
my simplification assumes that there are no duplicates.

If the numbers are not in order:
Use the following array to get the lower number and
=MAX(IF(A1:A8<=C1,A1:A8))
and
=MIN(IF(A1:A8D1,A1:A8))
to get the upper number

These two formulas assume the number you want to check for is in C1 and the
first formula is entered in D1

These must be entered by pressing Shift+Ctrl+Enter

--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"Mortir" wrote:



sorry made a slight mistake above:
- for 21, the solution should be 7 and 31 not 32

  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,346
Default Searching for low and high number

And one more optional change, instead of reference the first formula in the
second one you could just use

=MIN(IF(A1:A8C1,A1:A8))

Where C1 is the number you are comparing to.

--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"Shane Devenshire" wrote:

Hi,

It would be nice to use the BETWEEN function, ha! but there isn't one in
Excel.

You can make a minute simplification to the previous suggestion
=MIN(IF(A1:A8D1,A1:A8))
since by definition you don't want the min and max to be the same. This
assumes that your first formula is in D1

Of course these suggestions assume that the data is in Ascending order and
my simplification assumes that there are no duplicates.

If the numbers are not in order:
Use the following array to get the lower number and
=MAX(IF(A1:A8<=C1,A1:A8))
and
=MIN(IF(A1:A8D1,A1:A8))
to get the upper number

These two formulas assume the number you want to check for is in C1 and the
first formula is entered in D1

These must be entered by pressing Shift+Ctrl+Enter

--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"Mortir" wrote:



sorry made a slight mistake above:
- for 21, the solution should be 7 and 31 not 32



  #11   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Searching for low and high number

Shane

since by definition you don't want the min and max to be the same.


By definition that's precisely what the OP wanted

and if the number equals one of the numbers in the column the
solution should be the exact number if i have 31 the solution should
be 31


Mike


"Shane Devenshire" wrote:

Hi,

It would be nice to use the BETWEEN function, ha! but there isn't one in
Excel.

You can make a minute simplification to the previous suggestion
=MIN(IF(A1:A8D1,A1:A8))
since by definition you don't want the min and max to be the same. This
assumes that your first formula is in D1

Of course these suggestions assume that the data is in Ascending order and
my simplification assumes that there are no duplicates.

If the numbers are not in order:
Use the following array to get the lower number and
=MAX(IF(A1:A8<=C1,A1:A8))
and
=MIN(IF(A1:A8D1,A1:A8))
to get the upper number

These two formulas assume the number you want to check for is in C1 and the
first formula is entered in D1

These must be entered by pressing Shift+Ctrl+Enter

--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"Mortir" wrote:



sorry made a slight mistake above:
- for 21, the solution should be 7 and 31 not 32

  #12   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default Searching for low and high number

for high number
=INDEX(A1:A8,MATCH(B1,A1:A8,1)+1,0)


If the lookup_value *is* the high number that will return an error.


--
Biff
Microsoft Excel MVP


"muddan madhu" wrote in message
...
for low number
=INDEX(A1:A8,MATCH(B1,A1:A8,1),0)

for high number
=INDEX(A1:A8,MATCH(B1,A1:A8,1)+1,0)

On Jan 25, 10:55 pm, Mortir wrote:
I have the following example

A column with number of days:

days
3
7
31
61
91
181
271
365

Now i have a certain formula which returns to me a number of days -
for example 21. 21 belongs in between 7 and 31 in the days column. I
am looking for a formulas that would return this high and low number
of the interval in which my number belongs to:

- for 21, the solution should be 7 and 32,
- for 183, the solution should be 181 and 271
- and if the number equals one of the numbers in the column the
solution should be the exact number if i have 31 the solution should
be 31

is there a way to do this. thanx for your help!



  #13   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,346
Default Searching for low and high number

Absolutely, I just wanted to make this point which might be useful if others
are looking for a slightly different answer or the OP misstated the goal.
For example, I don't believe the OP stated that the numbers had to be in
ascending order nor that there were no duplicates, nor how to handle
duplicated if they occured.

--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"Mike H" wrote:

Shane

since by definition you don't want the min and max to be the same.


By definition that's precisely what the OP wanted

and if the number equals one of the numbers in the column the
solution should be the exact number if i have 31 the solution should
be 31


Mike


"Shane Devenshire" wrote:

Hi,

It would be nice to use the BETWEEN function, ha! but there isn't one in
Excel.

You can make a minute simplification to the previous suggestion
=MIN(IF(A1:A8D1,A1:A8))
since by definition you don't want the min and max to be the same. This
assumes that your first formula is in D1

Of course these suggestions assume that the data is in Ascending order and
my simplification assumes that there are no duplicates.

If the numbers are not in order:
Use the following array to get the lower number and
=MAX(IF(A1:A8<=C1,A1:A8))
and
=MIN(IF(A1:A8D1,A1:A8))
to get the upper number

These two formulas assume the number you want to check for is in C1 and the
first formula is entered in D1

These must be entered by pressing Shift+Ctrl+Enter

--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"Mortir" wrote:



sorry made a slight mistake above:
- for 21, the solution should be 7 and 31 not 32

  #14   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Searching for low and high number

Shane,

Ah I see, you mean a formula like mine which copes with duplicates and
random sorted numbers.

Mike

"Shane Devenshire" wrote:

Absolutely, I just wanted to make this point which might be useful if others
are looking for a slightly different answer or the OP misstated the goal.
For example, I don't believe the OP stated that the numbers had to be in
ascending order nor that there were no duplicates, nor how to handle
duplicated if they occured.

--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"Mike H" wrote:

Shane

since by definition you don't want the min and max to be the same.


By definition that's precisely what the OP wanted

and if the number equals one of the numbers in the column the
solution should be the exact number if i have 31 the solution should
be 31


Mike


"Shane Devenshire" wrote:

Hi,

It would be nice to use the BETWEEN function, ha! but there isn't one in
Excel.

You can make a minute simplification to the previous suggestion
=MIN(IF(A1:A8D1,A1:A8))
since by definition you don't want the min and max to be the same. This
assumes that your first formula is in D1

Of course these suggestions assume that the data is in Ascending order and
my simplification assumes that there are no duplicates.

If the numbers are not in order:
Use the following array to get the lower number and
=MAX(IF(A1:A8<=C1,A1:A8))
and
=MIN(IF(A1:A8D1,A1:A8))
to get the upper number

These two formulas assume the number you want to check for is in C1 and the
first formula is entered in D1

These must be entered by pressing Shift+Ctrl+Enter

--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"Mortir" wrote:



sorry made a slight mistake above:
- for 21, the solution should be 7 and 31 not 32

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
Return a High Number Anthony Excel Worksheet Functions 6 February 25th 08 03:25 PM
formula to throw out high number and low number Deb Excel Worksheet Functions 8 September 16th 07 06:51 AM
change the color of a number when it gets too high EJRI Excel Discussion (Misc queries) 1 September 1st 06 10:44 PM
Searching a Range for a number over 40 annem Excel Worksheet Functions 2 January 6th 06 03:59 PM
Searching and returning row number of a value MikeDH Excel Worksheet Functions 1 August 9th 05 06:06 PM


All times are GMT +1. The time now is 04:40 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"