Returning Adjacent Cell with Max(IF

pmolan

New Member
Joined
Dec 15, 2017
Messages
2
Office 365
I am working with a large spreadsheet that changes monthly. I prefer my code to be dynamic because the quantity of data changes each month. I have a summary page that displays the MAX of each ITEM.
I am currently using MAX(IF to find these values. I would like to also display the adjacent cells (to the left) of the found MAX value.

The data is structured something like this:

[TABLE="width: 188"]
<colgroup><col width="62" style="width: 47pt;"> <col width="62" style="width: 47pt;" span="2"> <col width="62" style="width: 47pt;"> <tbody>[TR]
[TD="class: xl80, width: 62, bgcolor: transparent"]ITEM[/TD]
[TD="class: xl82, width: 62, bgcolor: #FFFFCC"]Column 1[/TD]
[TD="class: xl82, width: 62, bgcolor: #FFFFCC"]Column 2[/TD]
[TD="class: xl83, width: 62, bgcolor: #FFFFCC"]Column 3[/TD]
[/TR]
[TR]
[TD="class: xl81, bgcolor: transparent"]Apple[/TD]
[TD="class: xl84, bgcolor: transparent"]2[/TD]
[TD="class: xl84, bgcolor: transparent"]57[/TD]
[TD="class: xl84, bgcolor: transparent"]9.2[/TD]
[/TR]
[TR]
[TD="class: xl81, bgcolor: transparent"]Apple[/TD]
[TD="class: xl84, bgcolor: transparent"]3[/TD]
[TD="class: xl84, bgcolor: transparent"]63[/TD]
[TD="class: xl84, bgcolor: transparent"]9.3[/TD]
[/TR]
[TR]
[TD="class: xl81, bgcolor: transparent"]Apple[/TD]
[TD="class: xl85, bgcolor: yellow"]4[/TD]
[TD="class: xl85, bgcolor: yellow"]69[/TD]
[TD="class: xl85, bgcolor: yellow"]15[/TD]
[/TR]
[TR]
[TD="class: xl81, bgcolor: transparent"]Apple[/TD]
[TD="class: xl84, bgcolor: transparent"]5[/TD]
[TD="class: xl84, bgcolor: transparent"]81[/TD]
[TD="class: xl84, bgcolor: transparent"]9.2[/TD]
[/TR]
[TR]
[TD="class: xl81, bgcolor: transparent"]Apple[/TD]
[TD="class: xl84, bgcolor: transparent"]6[/TD]
[TD="class: xl84, bgcolor: transparent"]87[/TD]
[TD="class: xl84, bgcolor: transparent"]8.8[/TD]
[/TR]
[TR]
[TD="class: xl81, bgcolor: transparent"]Plum[/TD]
[TD="class: xl86, bgcolor: #92D050"]2[/TD]
[TD="class: xl86, bgcolor: #92D050"]57[/TD]
[TD="class: xl86, bgcolor: #92D050"]15[/TD]
[/TR]
[TR]
[TD="class: xl81, bgcolor: transparent"]Plum[/TD]
[TD="class: xl84, bgcolor: transparent"]3[/TD]
[TD="class: xl84, bgcolor: transparent"]63[/TD]
[TD="class: xl84, bgcolor: transparent"]8.5[/TD]
[/TR]
[TR]
[TD="class: xl81, bgcolor: transparent"]Plum[/TD]
[TD="class: xl84, bgcolor: transparent"]4[/TD]
[TD="class: xl84, bgcolor: transparent"]69[/TD]
[TD="class: xl84, bgcolor: transparent"]7.9[/TD]
[/TR]
[TR]
[TD="class: xl81, bgcolor: transparent"]Plum[/TD]
[TD="class: xl84, bgcolor: transparent"]5[/TD]
[TD="class: xl84, bgcolor: transparent"]81[/TD]
[TD="class: xl84, bgcolor: transparent"]8.8[/TD]
[/TR]
[TR]
[TD="class: xl81, bgcolor: transparent"]Plum[/TD]
[TD="class: xl84, bgcolor: transparent"]6[/TD]
[TD="class: xl84, bgcolor: transparent"]87[/TD]
[TD="class: xl84, bgcolor: transparent"]8.7[/TD]
[/TR]
</tbody>[/TABLE]


On the summary page, B35 = "Plum" in the following code
The formula that I am using is:
=MAX(IF('Combined Data'!$A:$A=B35,'Combined Data'!$D:$D)) (CTRL + SHIFT + ENTER)
this returns a value of 15 which is correct

I would like to display columns B and C in my report as well
Example:

B35
Plum 2 57 15

I have tried code like
=INDEX('Combined Data'!$B:$B,MATCH(MAX(IF('Combined Data'!$A:$A=B35,'Combined Data'!$D:$D)),'Combined Data'!$D:$D,0))
This results in erroneous data such as

B35
Plum 4 69 15

because it is returning the first value that it finds in column B that has 15 in column D.

I know there is a simpler way with OFFSET etc.. but I just cant seem to get it to work with MAX(IF.

I hope that this is clear.

Thanks.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
You can't just assume that the plum and 15 combination occurs just once. So, a single output record like Plum 2 57 15 won't work. Just replace 8.8 in column D of Combined Data with 15 to see what I mean.
 
Upvote 0
Thank you for your reply. I agree there may be multiple 15’s. I am only interested in the first occurrence at the moment.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
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