Find the month and year of the highest number in a range.

anwaee2

Board Regular
Joined
Sep 13, 2012
Messages
151
Office Version
  1. 2011
Platform
  1. MacOS
I have the months of the year in A6 thru A17 on the "Summary" worksheet.

I have the years 2018 thru 2030 in the cells B4 thru N4 on the "Summary" worksheet.

I have the total monthly rainfall in cells B6 thru N17 in their respective cells according to month and year on the "Summary" worksheet.

I have the highest monthly rainfall amount in cell AA39 on the "Data" worksheet with the formula: =IFERROR(MAX(Summary!B6:N17),"")

I would like to have the month and year of the highest monthly rainfall in another cell such as Z39 on the "Data" worksheet.



Is there a way of doing this?

Thanks in advance for any help I may get on this. And thanks again for all the help in the past.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
I have the highest monthly rainfall amount in cell AA39 on the "Data" worksheet with the formula: =IFERROR(MAX(Summary!B6:N17),"")
To get the year
=INDEX(Summary!B4:N4,AGGREGATE(15,6,(COLUMN(Summary!B4:N4)-COLUMN(Summary!B4)+1)/(Summary!B6:N17=AA39),1))

To get the month
=INDEX(Summary!A6:A17,AGGREGATE(15,6,(ROW(Summary!A6:A17)-ROW(Summary!A6)+1)/(Summary!B6:N17=AA39),1))

M.
 
Upvote 0
I would have thought it possible that the maximum highest monthly rainfall could occur more than once in 13 years.
If that were to happen, what result would you want?

As it stands, Marcelo's formulas work fine if it is a single maximum but may produce a completely wrong result if that maximum did occur more than once. I have condensed it down to a single sheet here to demonstrate.

anwaee2.xlsm
ABCDEFGHIJKLMNOPQ
42018201920202021202220232024202520262027202820292030Max
5500
6January81393399443674416382429184189424395
7February92429212226138440152102495500340278361
8March12243644802172383103445274419154190February2024
9April10146620524822139949205434375128104267
10May247309417475318150117120220193495314396
11June1103581992832773966014831419641138076
12July904703874101617914847042143019338472
13August2081972102812582135003345943455105217
14September3971722464711553593682823613141023034
15October519639513137424217388273346472350158
16November3932132260152231457196210313428267244
17December34332425346336335337306321362755061
Summary
Cell Formulas
RangeFormula
Q5Q5=IFERROR(MAX(B6:N17),"")
P8P8=INDEX(A6:A17,AGGREGATE(15,6,(ROW(A6:A17)-ROW(A6)+1)/(B6:N17=Q5),1))
Q8Q8=INDEX(B4:N4,AGGREGATE(15,6,(COLUMN(B4:N4)-COLUMN(B4)+1)/(B6:N17=Q5),1))


Perhaps even something like this?

anwaee2.xlsm
ABCDEFGHIJKLMNOPQR
42018201920202021202220232024202520262027202820292030MaxCount
55002
6January81393399443674416382429184189424395
7February92429212226138440152102495500340278361
8March12243644802172383103445274419154190MultipleMultiple
9April10146620524822139949205434375128104267
10May247309417475318150117120220193495314396
11June1103581992832773966014831419641138076
12July904703874101617914847042143019338472
13August2081972102812582135003345943455105217
14September3971722464711553593682823613141023034
15October519639513137424217388273346472350158
16November3932132260152231457196210313428267244
17December34332425346336335337306321362755061
Summary
Cell Formulas
RangeFormula
Q5Q5=IFERROR(MAX(B6:N17),"")
R5R5=COUNTIF(B6:N17,Q5)
P8P8=IF(R5>1,"Multiple",INDEX(A6:A17,AGGREGATE(15,6,(ROW(A6:A17)-ROW(A6)+1)/(B6:N17=Q5),1)))
Q8Q8=IF(R5>1,"Multiple",INDEX(B4:N4,AGGREGATE(15,6,(COLUMN(B4:N4)-COLUMN(B4)+1)/(B6:N17=Q5),1)))
 
Upvote 0
Perhaps even something like this?
.. or this?

anwaee2.xlsm
ABCDEFGHIJKLMNOPQRST
42018201920202021202220232024202520262027202820292030Max
5500
6January81393399443674416382429184189424395
7February92429500226138440152102495500340278361MonthYear
8March12243644802172383103445274419154190February202023
9April10146620524822139949205434375128104267August202487
10May247309417475318150117120220193495314396February2027210
11June1103581992832773966014831419641138076    
12July904703874101617914847042143019338472    
13August2081972102812582135003345943455105217    
14September3971722464711553593682823613141023034    
15October519639513137424217388273346472350158
16November3932132260152231457196210313428267244
17December34332425346336335337306321362755061
Summary
Cell Formulas
RangeFormula
Q5Q5=IFERROR(MAX(B6:N17),"")
P8:P14P8=IF(S8="","",INDEX(A$6:A$17,S8))
Q8:Q14Q8=IF(T8="","",INDEX(B$4:N$4,T8))
S8:S14S8=IF(T8="","",AGGREGATE(15,6,(ROW(B$6:N$17)-ROW(B$6)+1)/((B$6:N$17=Q$5)*(COLUMN(B$6:N$17)-COLUMN(B$6)+1=T8)),COUNTIF(T$8:T8,T8)))
T8:T14T8=IFERROR(AGGREGATE(15,6,(COLUMN(B$6:N$17)-COLUMN(B$6)+1)/(B$6:N$17=Q$5),ROWS(Y$8:Y8)),"")
 
Last edited:
Upvote 0
Formulas to deal with multiple Maximums

Pasta1
ABCDEFGHIJKLMNOPQ
1MaxCount
25007
3
42018201920202021202220232024202520262027202820292030
5YearMonth
6January813933994436744163824291841895003952018March
7February924292125001384401521024955003402783612021February
8March50024364480217235001034452744191541902021May
9April101466205248221399492054343751281042672024March
10May2473094175003181501171202201934953143962024August
11June11035819928327739660148314196411380762027February
12July9047038741016179148470421430193384722029January
13August2081972102812582135003345943455105217  
14September3971722464711553593682823613141023034
15October519639513137424217388273346472350158
16November3932132260152231457196210313428267244
17December34332425346336335337306321362755061
Plan7
Cell Formulas
RangeFormula
P2P2=MAX(B6:N17)
Q2Q2=COUNTIF(B6:N17,P2)
P6:P13P6=IF(ROWS(P$6:P6)>$Q$2,"",INDEX(B$4:N$4,AGGREGATE(15,6,(COLUMN(B$4:N$4)-COLUMN(B$4)+1)/(B$6:N$17=$P$2),ROWS(P$6:P6))))
Q6:Q13Q6=IF(P6="","",INDEX(A$6:A$17,AGGREGATE(15,6,(ROW(A$6:A$17)-ROW(A$6)+1)/(INDEX($B$6:$N$17,0,MATCH(P6,B$4:N$4,0))=$P$2),COUNTIF(P$6:P6,P6))))


M.
 
Upvote 0
Formulas to deal with multiple Maximums
.. and some more.

anwaee2.xlsm
ABCDEFGHIJKLMNOPQ
1MaxCount
25007
3
42018201920202021202220232024202520262027202820292030
5YearMonth
6January813933994436744163824291841895003952018March
7February924292125001384401521024955003402783612021February
8March50024364480217235001034452744191541902021May
9April101466205248221399492054343751281042672024March
10May2473094175003181501171202201934953143962024August
11June11035819928327739660148314196411380762027February
12July9047038741016179148470421430193384722029January
13August2081972102812582135003345943455105217  
14September3971722464711553593682823613141023034
15October519639513137424217388273346472350158
16November3932132260152231457196210313428267244
17December34332425346336335337306321362755061
Sheet2
Cell Formulas
RangeFormula
P2P2=MAX(B6:N17)
Q2Q2=COUNTIF(B6:N17,P2)
P6:P13P6=IF(ROWS(T$6:T6)>Q$2,"",AGGREGATE(15,6,B$4:N$4/(B$6:N$17=P$2),ROWS(P$6:P6)))
Q6:Q13Q6=IF(P6="","",INDEX(A:A,AGGREGATE(15,6,ROW(A$6:A$17)/(INDEX(B$6:N$17,0,P6-B$4+1)=P$2),COUNTIF(P$6:P6,P6))))
 
Upvote 0
Another way:

Book1
ABCDEFGHIJKLMNOP
1Max
2500
3
42018201920202021202220232024202520262027202820292030
5Month&Year
6January81393399443674416382429184189500395Mar 2018
7February92429212500138440152102495500340278361Feb 2021
8March5002436448021723500103445274419154190May 2021
9April10146620524822139949205434375128104267Mar 2024
10May247309417500318150117120220193495314396Aug 2024
11June1103581992832773966014831419641138076Feb 2027
12July904703874101617914847042143019338472Jan 2029
13August2081972102812582135003345943455105217 
14September3971722464711553593682823613141023034 
15October519639513137424217388273346472350158 
16November3932132260152231457196210313428267244 
17December34332425346336335337306321362755061
Sheet1
Cell Formulas
RangeFormula
P2P2=MAX(B6:N17)
P6:P16P6=IFERROR(AGGREGATE(15,6,($A$6:$A$17&$B$4:$N$4)/($B$6:$N$17=$P$2),ROWS($P$6:P6)),"")
 
Upvote 0
Another way:
I had followed Marcelo's method of month/year results in separate cells, but re-reading post #1, I think you are right on in producing both in a single cell. (y)
 
Upvote 0
Thanks to all for the help. Unfortunately the only one that worked for me was the one from Petter-SSs. I converted it to look like the result that Phuoc got. The others either gave me a blank cell or a #Num! error for the month, the year was fine. I wonder if that was because I have a lot (mostly) of empty cells since it is not 2022-2030 yet. Thanks again to all, the Mr. Excel board is the best.
 
Upvote 0

Forum statistics

Threads
1,215,461
Messages
6,124,955
Members
449,199
Latest member
Riley Johnson

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