How to condense a nested MIN/MAX formula in IF statement

JamesonMH

Board Regular
Joined
Apr 17, 2018
Messages
120
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I want to somehow condense the red and blue sections below so my formula isn't so bulky.

Background: this formula is returning the first or last invoice date for select products depending on drop-down selection. All works fine... But

Is there a way to condense this so I don't have to re-write majority of formula over just for 1 criteria change (i.e. IF cell E638 says "Last" then MAX.... vs. IF "First" then MIN)

{=INDEX($F$642:$F$648,SUMPRODUCT(IF(E638="Last",MAX(IF($E$642:$E$648=E637,($E$642:$E$648=$E$637)*ROW($E$642:$E$648)))-ROW($F$642)+1,MIN(IF($E$642:$E$648=E637,($E$642:$E$648=$E$637)*ROW($E$642:$E$648)))-ROW($F$642)+1)),0)}


Thanks,
James
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Maybe...

=INDEX($F$642:$F$648,LARGE(IF($E$642:$E$648=E637,ROW($E$642:$E$648)-ROW($E$642)+1),IF(E638="Last",1,COUNTIF($E$642:$E$648,E637))))
Ctrl+Shift+Enter

Hope this helps

M.
 
Upvote 0
Maybe...

=INDEX($F$642:$F$648,LARGE(IF($E$642:$E$648=E637,ROW($E$642:$E$648)-ROW($E$642)+1),IF(E638="Last",1,COUNTIF($E$642:$E$648,E637))))
Ctrl+Shift+Enter

Hope this helps

M.

That absolutely does. Now the formula's half the size. Much cleaner to audit and more efficient. Thanks for your help Marcelo!

James
 
Upvote 0

Forum statistics

Threads
1,214,839
Messages
6,121,887
Members
449,057
Latest member
Moo4247

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