problem with the match_type in =match

Dan in Germany

New Member
Joined
Jun 17, 2007
Messages
29
Hi

I can use the match function to find the column that I need, however, when setting the match type I would like to have the function find the closest match regardless if the number is higher or lower that what I'm searching for.

ex. I'm searching for number 49 in a matrix

35 40 45 50

when match type is set to 1, the result would be column 3 and not column 4, even though 49 is actually closer to 50 and would be a better match. I know that I would get a better match in this case if I reverse the matrix and put it in descending order and set the match_type to -1. However, I MUST leave the the matrix in ascending order because the column number is associated with a particular growth class, and the data has different match_type requirements (some data needs to be matched with -1 and some with +1, some data doesn't matter)

Is there a way around this problem or is there another formula to use? I just want a formula which tells me in which column a certain number lies, and if theres no exact match, it should tell me in which column the closes match is to be found.
thanks alot
Dan
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
If the values always increase by 5 you could simply add 2,5 to your search value.
 
Upvote 0
Hello Dan,

<table border="1" cellspacing="0" cellpadding="0" style="font-family:Arial,Arial; font-size:10pt; background-color:#ffffff; padding-left:2pt; padding-right:2pt; "> <colgroup><col style="font-weight:bold; width:30px; " /><col style="width:80px;" /><col style="width:80px;" /><col style="width:80px;" /><col style="width:80px;" /><col style="width:80px;" /><col style="width:80px;" /></colgroup><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td > </td><td >A</td><td >B</td><td >C</td><td >D</td><td >E</td><td >F</td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >1</td><td style="font-family:Verdana; font-size:9pt; text-align:right; ">35</td><td style="text-align:right; ">40</td><td style="text-align:right; ">45</td><td style="text-align:right; ">50</td><td > </td><td style="background-color:#ffff00; text-align:right; ">4</td></tr></table>
<table style="font-family:Arial; font-size:10pt; border-style: groove ;border-color:#00ff00;background-color:#fffcf9; color:#000000; "><tr><td >Spreadsheet Formulas</td></tr><tr><td ><table border = "1" cellspacing="0" cellpadding="2" style="font-family:Arial; font-size:9pt;"><tr style="background-color:#cacaca; font-size:10pt;"><td >Cell</td><td >Formula</td></tr><tr><td >F1</td><td >=MATCH(ROUND<span style=' color:008000; '>(49/5,0)</span>*5,A1:D1,1)</td></tr></table></td></tr></table>
 
Upvote 0
Hi Dan

If the numbers are not evenly spaced (or not even sorted) you can use

for the closest match, in b4:

=INDEX($B$1:$F$1,MATCH(MIN(ABS($B$1:$F$1-B3)),ABS($B$1:$F$1-B3),0))
This in an array formula and so MUST be confirmed with CTRL+SHIFT+ENTER and not just ENTER.

if you prefer the column of the closest match, in b6:

=MATCH(MIN(ABS($B$1:$F$1-B3)),ABS($B$1:$F$1-B3),0)
... also confirmed with CTRL+SHIFT+ENTER.

Hope this helps
PGC
Book24.xls
ABCDEFGHI
1List:3538415053
2
3Number:39404446495236
4Closestmatch:38414150505335
5
6Closetmatchcolumn2334451
7
Sheet2
 
Upvote 0
Thanks for the quick response, it was very helpful and works on the example I gave. Unfortunately, I'm new to this board and had problems figuring out how to post a picture of my workbook to give a more practical example of what I'm working with.

Hopefully this example directly out of my workbook will help:
example for the forum.xls
ABCDEFGHIJKLMNOPQR
1GrowthClassincm
2LabnrZweigJggTL90growthclass1234567891011
3200503001186,463610295478929495
4200503001260,37461125334758626667
5200503001343,25461326374548
6200503001451,3637112842545557
720050300153683412162632363839
820050300169,992346910
Tabelle1


I hope this worked.

For those not from Germany, Vergleich=match. Basically, the field in red are good examples of my problem. I want to find the value of TL90 in the Matrix "Growth Class". Rounding would help in some situations but not all of them. The formula Beate gave me was great for my first example but I don't know how to apply it to my situation.
I hope the html maker works
Thanks for any help,
Dan
 
Upvote 0
Hi again

I'd like to say that you could use my 2nd formula but I am obviously missing something.

You said in your first post "I would like to have the function find the closest match regardless if the number is higher or lower that what I'm searching for."

- In row 3, the value is 86.4 and you choose class 6 (78) instead of class 7 (92). 86.4 - 78 = 8.4, 92 - 86.4 = 5.6. Why class 6? Isn't class 7 the closest match?
- In row 4, the value is 60.3 and you choose class 7 (58) instead of class 8 (62). 60.3 - 58 = 2.3, 62 - 60.3 = 1.7. Why class 7? Isn't class 8 the closest match?

Can you please explain?
My 2nd formula would give for those 2 rows 7 and 8, the closest matches.

Kind regards
PGC
 
Upvote 0
Thanks for the reply,

You pointed out my exact problem. I would prefer that the formula for row 3 gives the result of column 7 instead of column 6. The problem lies in the fact that the match formula, when NO exact match is found, will always give the column with next smallest match, hence column 6 in row 3, and column 7 in row 4.

I would like to have a formula give me the column with the closest match, but the results in the column "growth class" are the results of the match formula. (=match(D3,H3:R3,1)

I will continue with you formula, but unfortunately I'm getting the value error. Unfortunately I'm not too experienced with complicated formulas, I've mastered the If function and thats about as far as I go.

Thanks for the insightful replies!
Dan
 
Upvote 0
You are getting the value error because you are not confirming the formula with CTRL+SHIFT+ENTER.

For your example, in E3:

Code:
=MATCH(MIN(ABS($H3:$R3-$D3)),ABS($H3:$R3-$D3),0)
This in an array formula and so MUST be confirmed with CTRL+SHIFT+ENTER and not just ENTER.

If you confirm just with ENTER you'll get the #VALUE! error.

You can then copy it down.

Plese try it.

Hope this helps
PGC
 
Upvote 0
Hello Dan,
Excel Workbook
ABCDEFGHIJKLMNOPQR
1GrowthClassincm
2LabnrZweigJggTL90growthclass1234567891011
3200503001186,473610295478929495
4200503001260,38461125334758626667
5200503001343,26461326374548
6200503001451,3737112842545557
720050300153683412162632363839
820050300169,99234691
Sheet


Formula from cell E3 can be copied down.

And in german Excel the formula in E3 is:
{=VERGLEICH(INDEX(H3:R3;VERGLEICH(MIN(ABS(H3:R3-D3));ABS(H3:R3-D3);0));H3:R3;1)}
(Umrandende { } nicht miteingeben, sondern Formel mit STRG+SHIFT+RETURN abschließen!)


Pls refer to: http://www.excelformeln.de/formeln.html?welcher=65
 
Upvote 0

Forum statistics

Threads
1,215,260
Messages
6,123,926
Members
449,135
Latest member
NickWBA

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top