MATCH returns #N/A for a range that contains the value

aprill

New Member
Joined
Jul 22, 2005
Messages
8
Office Version
  1. 365
Platform
  1. MacOS
I use =MAX(C6:H900)to find the max value in a range. I put that value in K29. Then I try to use =MATCH(K29,C6:H900) to find that value in the range to return the row. MATCH returns #N/A. I checked the type of both K29 and the range and they are both v. If I use =MATCH(K29,K29), a 1 is returned. So MATCH does seem to find the value but as soon as I expand the range, MATCH returns #N/A. I am using Excel Version 16.40. I could really use some help.
 

Attachments

  • Screen Shot 2020-09-04 at 9.22.41 PM.png
    Screen Shot 2020-09-04 at 9.22.41 PM.png
    161.6 KB · Views: 20

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
This ARRAY formula (CTRL+Shift+Enter) will find the cell address which you could modify to just grab the row number:

Code:
=ADDRESS(SUM(IF(C6:H900=MAX(C6:H900),ROW(C6:H900))),SUM(IF(C6:H900=MAX(C6:H900),COLUMN(C6:H900))))

If the cell address from above is in K8, this formula will give you the row.

Code:
=VALUE(RIGHT(K8,LEN(K8) - MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},K8&"0123456789")) +1))
 
Upvote 0
I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Is it possible with your data that the max value can occur more than once in the range? If so, what result(s) do you want returned & what layout?

One of these will give you the first row depending on whether you want the actual row number or the relative row number in the table.

20 09 05.xlsm
CDEFGHIJK
1
2
3
4
5
6484884563534194392
7685165371118196420
834140249261997245
9569714922561858891965
107229382707831355028
116981123383044192313
12271217599946617292
13467344482717965726
14258581327100736169
15771159662394651199
16945256267295547840
1722985293614187628
18275759470127208416
19503965467327769788
20576614318556332854
21940273598726158
22544529666304719794
2390253987562755464
2435828734651480844
Max_Row
Cell Formulas
RangeFormula
K9K9=MAX(C6:H900)
K10K10=AGGREGATE(15,6,ROW(C6:H25)/(C6:H25=K9),1)-ROW(C6)+1
K11K11=AGGREGATE(15,6,ROW(C6:H25)/(C6:H25=K9),1)



If the cell address from above is in K8, this formula will give you the row.

Code:
=VALUE(RIGHT(K8,LEN(K8) - MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},K8&"0123456789")) +1))
Much simpler would be
=REPLACE(K8,1,FIND("$",K8,2),"")+0
 
Upvote 0
@Peter_SSs ,

It's typo in your formula...
Your formula in K11 is:
=AGGREGATE(15,6,ROW(C6:H25)/(C6:H25=K9),1)

and should be:
=AGGREGATE(15,6,ROW(C6:H25)/(C6:H25=K9),1) + 1
 
Upvote 0
@Peter_SSs ,

It's typo in your formula...
Your formula in K11 is:
=AGGREGATE(15,6,ROW(C6:H25)/(C6:H25=K9),1)

and should be:
=AGGREGATE(15,6,ROW(C6:H25)/(C6:H25=K9),1) + 1
Why? With my sample data that would return 14 when the maximum value is in row 13. :confused:


I did have errors though as I tested on a smaller range and forgot to reinstate the OP's range. Corrected here.

20 09 05.xlsm
CDEFGHIJK
1
2
3
4
5
6484884563534194392
7685165371118196420
834140249261997245
9569714922561858891965
107229382707831355028
116981123383044192313
12271217599946617292
13467344482717965726
14258581327100736169
15771159662394651199
16945256267295547840
1722985293614187628
18275759470127208416
19503965467327769788
20576614318556332854
21940273598726158
22544529666304719794
2390253987562755464
2435828734651480844
Max_Row
Cell Formulas
RangeFormula
K9K9=MAX(C6:H900)
K10K10=AGGREGATE(15,6,ROW(C6:H900)/(C6:H900=K9),1)-ROW(C6)+1
K11K11=AGGREGATE(15,6,ROW(C6:H900)/(C6:H900=K9),1)
 
Upvote 0
Peter,

Why? With my sample data that would return 14 when the maximum value is in row 13. :confused:

Maybe I understand wrong...

Your formula - =AGGREGATE(15,6,ROW(C6:H900)/(C6:H900=K9),1) return 13 and the second 965 is in row 14

Row 1
484​
884​
563​
534​
194​
392​
Row 2
685​
165​
371​
118​
196​
420​
Row 3
341​
402​
492​
619​
97​
245​
Row 4
569​
714​
922​
561​
858​
891​
Row 5
722​
938​
270​
783​
135​
502​
Row 6
69​
811​
233​
830​
441​
923​
Row 7
271​
217​
599​
946​
617​
292​
Row 8
467​
344​
482​
717​
965
726​
Row 9
258​
581​
327​
100​
736​
169​
Row 10
771​
159​
662​
394​
651​
199​
Row 11
945​
256​
267​
295​
547​
840​
Row 12
229​
852​
93​
614​
187​
628​
Row 13
275​
759​
470​
127​
208​
416​
Row 14
503​
965
467​
327​
769​
788​
Row 15
576​
614​
318​
556​
332​
854​
Row 16
940​
273​
598​
72​
615​
8​
Row 17
544​
529​
666​
304​
719​
794​
Row 18
902​
539​
875​
627​
55​
464​
Row 19
358​
287​
34​
651​
480​
844​
 
Upvote 0
Maybe I understand wrong...

Your formula - =AGGREGATE(15,6,ROW(C6:H900)/(C6:H900=K9),1) return 13 and the second 965 is in row 14
Both of Peter's formulas are returning the first instance of 965. The first shows the position of the row in the table, the second shows the position in the sheet.

To find the position of the second 965 you would need to change the [k] value of AGGREGATE to 2. Using the same table as Peter in post 5.
Book1
K
9965
1014
1119
Sheet1
Cell Formulas
RangeFormula
K9K9=MAX(C6:H900)
K10K10=AGGREGATE(15,6,ROW(C6:H900)/(C6:H900=K9),2)-ROW(C6)+1
K11K11=AGGREGATE(15,6,ROW(C6:H900)/(C6:H900=K9),2)
 
Upvote 0
Both of Peter's formulas are returning the first instance of 965. The first shows the position of the row in the table, the second shows the position in the sheet.
Exactly, as I pointed out in my post.
One of these will give you the first row depending on whether you want the actual row number or the relative row number in the table.
 
Upvote 0
Thanks for your help. I am going to try aggregate but can anyone tell me why MATCH would not work?

April
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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