Use max() and left() in the same command - excel

I have data that looks like this and the format of the values is always the same.
entries
12aa
39aa
45ba
18ac
51cc
I want to get the max integer from the column without a helper column.
In this example, the formula would return 51.

If the format is always the same, as you show, with two digits and two alphabet, then simply:
=MAX(--LEFT(myRange,2))

Related

Excel - How to SUM the results of LEFT?

In row 2, I used =LEFT(B1,(FIND("/",B1,1)-1)) to get the 288 and ‭‭‭‭233‬‬‬‬. But when I tried to =SUM(B2:C2), it returned a 0. How do I SUM the results of LEFT()?
When you use LEFT() function then it returns result as string (not as number). So, you can not sum string. You need to convert string to number. You can use below formula
=LEFT(B1,(FIND("/",B1,1)-1))*1
Or use
=--LEFT(B1,(FIND("/",B1,1)-1))
Then sum output.
You can directly sum lefts before / by following formula.
=SUM(--LEFT(B1:C1,SEARCH("/",B1:C1)-1))
force the 288/233 to a number. the easiest way is =LEFT(B1,(FIND("/",B1,1)-1))+0

Using formatted text as match function lookup value

My look up array is of format DI-0001. First 3 places are fixed as “DI-“ and next 4 are any number but of fixed length of 4. My look up array is a simple number which is less than 10000. Hence always equals to less than 4 digits. I formatted my lookup value column as “DI-“0000 so as to match the lookup array. But now my match function is breaking down, giving #N/A error. I understand the error, but don’t know how to overcome it.
You are not looking for a number in your look up array so you have to convert the value you are looking up to a string as well, not just format it as string.
=VLOOKUP("DI-"&TEXT(value,"0000"),array,2,0)
Or preferably,
=INDEX(B1:B9,MATCH("DI-"&TEXT(F1,"0000"),A1:A9,0))

Returning a specific value from a string

2.375;26.375;0.743|98.375;26.375;0.743|98.375;2.375;0.743|2.375;***2.375***;0.743|2.375;26.375;0.743555
I'm trying to return the second value equaling 2.375 after the 3rd "|". What's the best way to do this?
Thanks!
Asuming the string is in cell A1 (and the numbers are always 5 chars in length), the following formula will work:
=MID(A1,FIND(";",A1,FIND("|",A1,FIND("|",A1,FIND("|",A1)+1)+1)+1)+1,5)
OR - to handle any length number you can do this:
=MID(A1,FIND(";",A1,FIND("|",A1,FIND("|",A1,FIND("|",A1)+1)+1)+1)+1,FIND(";",A1,FIND(";",A1,FIND("|",A1,FIND("|",A1,FIND("|",A1)+1)+1)+1)+1)-FIND(";",A1,FIND("|",A1,FIND("|",A1,FIND("|",A1)+1)+1)+1)-1)
This formula will bring the second number after the third | regardless of size.
=--TRIM(MID(SUBSTITUTE(TRIM(MID(SUBSTITUTE(A1,"|",REPT(" ",999)),3*999,999)),";",REPT(" ",999)),999,999))
We can easily make this formula dynamic:
=--TRIM(MID(SUBSTITUTE(TRIM(MID(SUBSTITUTE(A4,"|",REPT(" ",999)),(C1-1)*999+1,999)),";",REPT(" ",999)),(C2-1)*999+1,999))
This will allow you to specify the group and the sequence in that group to return the desired number.

Excel Vlookup - multiple lookup values?

is it possible to use something like this in vlookup() ?
=vlookup(or(1,2,3,4), a1:c10, 2)
I want to find the first instance in column A that contains the numbers 1-4
You can't use VLOOKUP for this, but you can do it with the help of MATCH.
Try this (using array formula -> ctrl+shift+enter):
{=INDEX(B1:B10,MIN(IFERROR(MATCH({1;2;3;4},A1:A10,0), FALSE)))}
The idea is to match against 1-4 to get the index, convert errors to non-errors (FALSE), then get the minimum row number. Then that row number is used as an index to the values column.

Excel - Return the first negative number of a column

I'm using Excel 2010 and I'm looking for a way to return the first negative number of a column. For instance, I have the following numbers distributed in a column:
1
4
6
-3
4
-1
-10
8
Which function could I use to return -3?
Thanks!
This could be interpreted two ways... If all the numbers are in a single cell (one column) as a string, the MID function can be used. If the numbers are in A1, a formula that could work is this:
=VALUE(MID(A1,SEARCH("-",A1),SEARCH(" ",A1,SEARCH("-",A1))-SEARCH("-",A1)))
If the numbers are each in their own columns (in my example, A3:H3), a different technique must be used:
{=INDEX(A3:H3,1,MATCH(TRUE,A3:H3<0,0))}
Don't type the { } - enter the equation using CTRL+SHIFT+ENTER.
In each case, the formula will return the number -3, which is the first negative number in the series.
Another possibility, avoiding the array formula (which are a big source of performance issues):
=LOOKUP(1;1/(M2:M15<0);M2:M15)
(I assume your numbers are in the M2:M15 range).
This will return the first number matching the "<0" condition. You may use any other condition, including text comparisons.
You may also extract the value of another array corresponding to the matching cell:
=LOOKUP(1;1/(M2:M15<>"OK");T2:T15)
In this example, the first cell containing another string than "OK" will be searched for in the m2:m15 array and the corresponding value in array t2:t15 will be returned.
Please note that the usage of the lookup function should be avoided whenever possible (but in this case, it's very handy !)
(I got the original inspiration for this answer from this post)

Resources