# Using an IF statement to sort data

I am attempting to identify the minimum value occurs before the maximum value, but would like to know if there is a function that I can use, rather than using a macro.

In detail, in row 4, I find the minimum value of 2 and the maximum value of 410.  I would like to return the date (the header row) of the minimum value and the date of the maximum value IF the minimum value occurs before the maximum value.  If the maximum value occurs before, then return nothing.

I have been racking my brain with an IF statement or a combination of IF and range, but am drawing  a blank.  I have a sparkline in place to help visualize how the values fluctuate.
###### Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x

AstronautCommented:
In row 4, use these formulas...

=IF(MATCH(MIN(C4:V4), C4:V4, 0)<MATCH(MAX(C4:V4), C4:V4, 0), INDEX(C\$2:V\$2, MATCH(MIN(C4:V4), C4:V4, 0)), "")
=IF(MATCH(MIN(C4:V4), C4:V4, 0)<MATCH(MAX(C4:V4), C4:V4, 0), INDEX(C\$2:V\$2, MATCH(MAX(C4:V4), C4:V4, 0)), "")

Note that if the Min or Max values occur twice, only the date for the first occurrence will be returned.
0

EngineerCommented:
Did you intend to upload a file?
0

Author Commented:
I did. Sorry.  here it is.
SAMPLE.xlsx
0

Author Commented:
Thank you for your help.  This works.
0