Returning a string based on the answer of a function

Pighouse

Okay, so I want to have a function (that isn't insanely long) that will display a string based on which value is given of a MIN function. I'll give an example of a formula I've already made, but this isn't compact at all with more formulas in the MIN list, so there's probably a better way to make it (I'm sort of new at excel).

=IF(MIN(5+5, 10/2, 13, 16-14)=5+5, "Function 1", IF(MIN(10/2, 13, 16-14)=10/2, "Function 2", IF(MIN(13, 16-14)=13, "Function 3", "Function 4")))

In the example, the formula checks to see if the MIN is the first value, and if it is, it displays "Function 1", but if it isn't, it checks again, but with the second value, and so on until it checks for the final value. The optimal formula for me would be one where I only need to input the MIN function once, but any help is appreciated. Let me know if this question is a little vague and I'll try to explain it more clearly.

Thanks!

Edit 1: Instead of returning "Function 1", "Function 2" etc., I need the function to return two words; the first word determined from a list that checks the row number and changes every two rows (e.g. T1 and T2 are "First", T3 and T4 are "Second", etc.) and the second word that switches every row (e.g. T1 is "Word", T2 is "Example", T3 is "Word", T4 is "Example", etc.). So the final result, once getting the MIN from T1 would return "First Word", T2 would be "First Example", T3 "Second Word", T4 "Second Example" and so on.

Edit 2: Alright, I managed to figure it out with some help with the MATCH command. My final result was something like:

=CHOOSE(EVEN(MATCH(MIN(T2:T4),T2:T4,0))/2,"First","Second") & CHOOSE((MOD(MATCH(MIN(T2:T3),T2:T3,0),2)+1), " Example", " Word")

This function finds the first word by finding the MIN, MATCHEs it to the row number, making it even and dividing it by 2 and then assigning that number to a string. Then it finds the second word by finding the MIN, MATCHing it to the row number, getting the MOD of 2, adding 1 [because it can't be 0] and then assigning that number to a string. This function is extremely compact and only requires that I add more to the list of MINs in the cells of my choosing.

Gary's Student

You can process an unlimited (really 1,048,576 ) number of expressions with a simple formula.

List the expressions in say column A, then in another cell enter:

="Function" & MATCH(MIN(A:A),A:A,0)

enter image description here

Where column A contains formulas or constants like:

enter image description here

Note:

If the minimum value appears more than once in the list, the formula returns the position of the first one.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related