Finding a value In a column between two numbers

%3CLINGO-SUB%20id%3D%22lingo-sub-957247%22%20slang%3D%22en-US%22%3EFinding%20a%20value%20In%20a%20column%20between%20two%20numbers%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-957247%22%20slang%3D%22en-US%22%3EI%20am%20trying%20to%20write%20a%20formula%20that%20is%20returning%20the%20highest%20matched%20number%20between%20a%20given%20range.%20For%20example.%20I%20want%20to%20return%20the%20highest%20match%20number%20between%2068%20to%20128%20for%20the%20following%20(this%20is%20A%20column.%20The%20number%20to%20the%20left%20before%20the%20dash%20is%20the%20row%20number)%3CBR%20%2F%3E1-%20530.4%3CBR%20%2F%3E2-%20296.8%3CBR%20%2F%3E3-%20187.6%3CBR%20%2F%3E4-%20159.3%3CBR%20%2F%3E5-%20147.7%3CBR%20%2F%3E6-%2074.4%3CBR%20%2F%3E7-%2061.1%3CBR%20%2F%3E8-%2058.2%3CBR%20%2F%3E9-%2050.1%3CBR%20%2F%3E10-%2036.9%3CBR%20%2F%3E11-%2027.7%3CBR%20%2F%3E12-%2026.8%3CBR%20%2F%3E13-%2016.2%3CBR%20%2F%3E14-%2014.3%3CBR%20%2F%3E15-%2010.6%3CBR%20%2F%3E16-%209.1%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-957247%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%20on%20mobile%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-957336%22%20slang%3D%22en-US%22%3ERe%3A%20Finding%20a%20value%20In%20a%20column%20between%20two%20numbers%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-957336%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F434082%22%20target%3D%22_blank%22%3E%40Jhardy78%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20think%20I%20have%20interpreted%20that%20you%20want%20to%20measure%20the%20degree%20of%20proximity%20of%20each%20of%20these%20numbers%20with%20the%20range%2068-128%2C%20or%20some%20other%20range.%3CBR%20%2F%3EI%20think%20it's%20a%20very%20interesting%20topic%3B%20I%20have%20applied%20the%20following%20formula%3A%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3D%20IF%20(AND%20(G4%26gt%3B%20%3D%2068%3B%20G4%20%26lt%3B%3D%20128)%3B%201%3B%20IF%20(G4%26gt%3B%20128%3B%20G4-128%3B%20SI%20(G4%20%26lt%3B68%3B%2068-G4%3B%200)))%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EThis%20formula%20assigns%201%20to%20the%20values%20that%20are%20within%20the%20range.%3CBR%20%2F%3ETo%20the%20values%20that%20are%20above%20the%20range%2C%20I%20attribute%20the%20value%20of%20the%20subtraction%20between%20the%20number%20and%20the%20maximum%20value%20of%20the%20range%3B%20and%20to%20those%20who%20are%20below%20the%20range%2C%20I%20attribute%20the%20subtraction%20between%20the%20minimum%20and%20the%20number.%3CBR%20%2F%3EThe%20lower%20the%20number%2C%20the%20closer%20to%20the%20range%20it%20will%20be.%3CBR%20%2F%3EIn%20the%20example%2C%20I%20used%2068%20and%20128%3B%20but%20these%20values%20can%20be%20written%20in%20two%20cells%20and%20you%20can%20refer%20to%20them.%3C%2FP%3E%3CP%3EHope%20this%20helps!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-957370%22%20slang%3D%22en-US%22%3ERe%3A%20Finding%20a%20value%20In%20a%20column%20between%20two%20numbers%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-957370%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F434082%22%20target%3D%22_blank%22%3E%40Jhardy78%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAssuming%20your%20numbers%20are%20in%20the%20range%20A1%3AA16%20then%20you%20may%20try%20this...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3DMAXIFS(A1%3AA16%2CA1%3AA16%2C%22%26gt%3B%3D68%22%2CA1%3AA16%2C%22%26lt%3B%3D128%22)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20required%2C%20instead%20of%20hard%20coding%20the%20criteria%2C%20you%20may%20mention%20the%20criteria%20in%20the%20cells%20and%20refer%20the%20criteria%20cells%20in%20the%20formula.%20So%20assuming%20the%20min%20criteria%20is%20in%20B1%20and%20max%20criteria%20is%20in%20C1%2C%20the%20criteria%20in%20the%20above%20formula%20would%20be%20%3CSTRONG%3E%22%26gt%3B%3D%22%26amp%3BB1%3C%2FSTRONG%3E%20and%20%3CSTRONG%3E%22%26lt%3B%3D%22%26amp%3BC1%3C%2FSTRONG%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20MAXIFS%20is%20not%20available%20with%20your%20version%2C%20you%20may%20try%20this%20%3CSTRONG%3EArray%20Formula%3C%2FSTRONG%3E%20which%20requires%20confirmation%20with%20%3CSTRONG%3ECtrl%2BShift%2BEnter%3C%2FSTRONG%3E%20instead%20of%20Enter%20alone.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3DMAX(IF((A1%3AA16%26gt%3B%3D68)*(A1%3AA16%26lt%3B%3D128)%2CA1%3AA16))%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3Eand%20confirm%20with%20Ctrl%2BShift%2BEnter.%3CBR%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-957548%22%20slang%3D%22en-US%22%3ERe%3A%20Finding%20a%20value%20In%20a%20column%20between%20two%20numbers%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-957548%22%20slang%3D%22en-US%22%3EYour%20top%20formula%20is%20returning%20the%20lowest%20number%20not%20the%20highest%20number%20but%20so%20close.%20The%20bottom%20formula%20I%20can%E2%80%99t%20get%20to%20work%20maybe%20because%20I%E2%80%99m%20using%20my%20Excel%20on%20my%20phone.%3CBR%20%2F%3E%3CBR%20%2F%3E*your%20assumption%20was%20correct%20with%20a1%3Aa16%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-957551%22%20slang%3D%22en-US%22%3ERe%3A%20Finding%20a%20value%20In%20a%20column%20between%20two%20numbers%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-957551%22%20slang%3D%22en-US%22%3EThanks%20Paul%20but%20that%20formula%20doesn%E2%80%99t%20make%20some%20sense%20to%20me%20since%20you%20are%20using%20G4%20and%20my%20array%20is%20in%20a1%3AA16.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-958054%22%20slang%3D%22en-US%22%3ERe%3A%20Finding%20a%20value%20In%20a%20column%20between%20two%20numbers%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-958054%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F434082%22%20target%3D%22_blank%22%3E%40Jhardy78%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhat%20do%20you%20mean%20exactly%20under%20%3CSTRONG%3Ematched%3C%2FSTRONG%3E%20number%2C%20matched%20with%20what%3F%20If%20that's%20the%20maximum%20number%20in%20the%20range%20(A1%3AA16)%20which%20is%20less%20than%20128%20and%20more%20than%2068%2C%20when%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394231%22%20target%3D%22_blank%22%3E%40Subodh_Tiwari_sktneer%3C%2FA%3E%20formula%20is%20correct%2C%20it%20returns%2074.4.%20And%20since%20it's%20the%20only%20number%20in%20the%20range%2C%20it%20simultaneously%20the%20smallest%20one.%20Another%20variant%20of%20non-array%20formula%20without%20MAXIFS%20is%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3DIFERROR(AGGREGATE(14%2C6%2C1%2F(%24A%241%3A%24A%2416%26lt%3B%3D128)%2F(%24A%241%3A%24A%2416%26gt%3B%3D68)*%24A%241%3A%24A%2416%2C1)%2C%22no%20such%22)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EOr%20you%20mean%20something%20more%20complex%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor
I am trying to write a formula that is returning the highest matched number between a given range. For example. I want to return the highest match number between 68 to 128 for the following (this is A column. The number to the left before the dash is the row number)
1- 530.4
2- 296.8
3- 187.6
4- 159.3
5- 147.7
6- 74.4
7- 61.1
8- 58.2
9- 50.1
10- 36.9
11- 27.7
12- 26.8
13- 16.2
14- 14.3
15- 10.6
16- 9.1
5 Replies
Highlighted

@Jhardy78 

I think I have interpreted that you want to measure the degree of proximity of each of these numbers with the range 68-128, or some other range.
I think it's a very interesting topic; I have applied the following formula:

= IF (AND (G4> = 68; G4 <= 128); 1; IF (G4> 128; G4-128; SI (G4 <68; 68-G4; 0)))

This formula assigns 1 to the values that are within the range.
To the values that are above the range, I attribute the value of the subtraction between the number and the maximum value of the range; and to those who are below the range, I attribute the subtraction between the minimum and the number.
The lower the number, the closer to the range it will be.
In the example, I used 68 and 128; but these values can be written in two cells and you can refer to them.

Hope this helps!

Highlighted

@Jhardy78 

Assuming your numbers are in the range A1:A16 then you may try this...

 

=MAXIFS(A1:A16,A1:A16,">=68",A1:A16,"<=128")

 

If required, instead of hard coding the criteria, you may mention the criteria in the cells and refer the criteria cells in the formula. So assuming the min criteria is in B1 and max criteria is in C1, the criteria in the above formula would be ">="&B1 and "<="&C1.

 

If MAXIFS is not available with your version, you may try this Array Formula which requires confirmation with Ctrl+Shift+Enter instead of Enter alone.

 

=MAX(IF((A1:A16>=68)*(A1:A16<=128),A1:A16))

and confirm with Ctrl+Shift+Enter.

Highlighted
Your top formula is returning the lowest number not the highest number but so close. The bottom formula I can’t get to work maybe because I’m using my Excel on my phone.

*your assumption was correct with a1:a16
Highlighted
Thanks Paul but that formula doesn’t make some sense to me since you are using G4 and my array is in a1:A16.
Highlighted

@Jhardy78 

What do you mean exactly under matched number, matched with what? If that's the maximum number in the range (A1:A16) which is less than 128 and more than 68, when @Subodh_Tiwari_sktneer formula is correct, it returns 74.4. And since it's the only number in the range, it simultaneously the smallest one. Another variant of non-array formula without MAXIFS is

=IFERROR(AGGREGATE(14,6,1/($A$1:$A$16<=128)/($A$1:$A$16>=68)*$A$1:$A$16,1),"no such")

Or you mean something more complex?