Excel Formula combining text fields - excel

I want make a formula which includes text and the output will be a different text also.
Like:
G8 = I am Red,
G9 = I am Green,
G10 = I am White.
Now, I need a formula which will give output like:
"Red" (in H8 field) when I enter "I am Red" and so on for other inputs.
I have tried with 'nested if', but only 7 nested if can be added, whereas I have at least 40+ values to input and need to get different output for those input.

Assuming your data is in column G starting G8, do the following:
Type in H8: =RIGHT(G8,LEN(G8)-MAX(IF(MID(G8,ROW(INDIRECT("1:"&LEN(G8))),1)=" ",ROW(INDIRECT("1:"&LEN(G8))),0))).
Press CTRL+SHIFT+ENTER instead of usual ENTER - this will define an ARRAY formula and will result in {} brackets around it (but do NOT type them manually!).
Autofill formula down your range.
It will return the last "word" in a string, or more exactly - part of string between the last space and its end, regardless of actual symbols.
Sample file: https://www.dropbox.com/s/dfkk1cqy1z0o3pz/ColorName.xlsx

A vlookup may work here. You would enter all data combinations, and then use vlookup, based on the "I am red" column, which would find the corresponding value in the table and return it. Depending on the type of data, you may have better success with the index and match method instead of vlookup.

Related

Splitting names given in single cells without using text to column excel

i want to use excel formula to split multiple names given in a single cell. dont want to use text to column feature. For example
in the above yellow is the variable name & the green color is the required format
See find the nth instance of a character: FIND(CHAR(1),SUBSTITUTE(string,delimiter,CHAR(1),nth)). For the first, we use LEFT(string,position_first-1). For the last: RIGHT(string,LEN(string)-position_last). For all in between: MID(string,position_first+1,position_second-position_first-1).
So, combining the logic, we may get this:
=IFERROR(IFERROR(IF(B$1=1,LEFT($A2,FIND(CHAR(1),SUBSTITUTE($A2,"/",CHAR(1),1),1)-1),MID($A2,FIND(CHAR(160),SUBSTITUTE($A2,"/",CHAR(160),B$1-1),1)+1,FIND(CHAR(1),SUBSTITUTE($A2,"/",CHAR(1),1+B$1-1),1)-FIND(CHAR(1),SUBSTITUTE($A2,"/",CHAR(1),B$1-1),1)-1)),RIGHT($A2,LEN($A2)-FIND(CHAR(1),SUBSTITUTE($A2,"/",CHAR(1),B$1-1),1))),"")
IFERROR(...,"") is used to return "" after last occurrence (below, in G2). Nested IFERROR(... RIGHT) will be triggered at last occurrence (since MID will fail there; below at F2).
Try using this:
With the full name in cell A2, the formulas go as follows:
Get the first name:
=LEFT(A2,SEARCH(" ",A2)-1)
Get the last name:
=RIGHT(A2,LEN(A2)-SEARCH(" ",A2,1))
You enter the formulas in cells B2 and C2, respectively, and drag the fill handle to copy the formulas down the columns. The result will look something similar to this:

Excel: dynamically calculate range next to a searched up cell

I am an occasional Excel user and stuck how to create a dynamic range.
After looking up a text in a table, how can I calculate the range next to this cell, up to the next empty row? Not using VBA.
Thanks for your help.
In H4, formula copied down :
=IFERROR(INDEX(INDEX(C:C,MATCH(F4,A:A,0)):C$1000,MATCH(G4,INDEX(B:B,MATCH(F4,A:A,0)):B$1000,0)),"")
Should you want a dynamic range,
Change C$1000 to INDEX(C:C,MATCH(9.9E+307,B:B)
and
Change B$1000 to INDEX(B:B,MATCH(9.9E+307,B:B))
Then
The H4 copied down formula become :
=IFERROR(INDEX(INDEX(C:C,MATCH(F4,A:A,0)):INDEX(C:C,MATCH(9.9E+307,B:B)),MATCH(G4,INDEX(B:B,MATCH(F4,A:A,0)):INDEX(B:B,MATCH(9.9E+307,B:B)),0)),"")
Edit :
As per Ron Rosenfeld's comment, "should B11 change to 24 and G4 change to 24"
The "Source Table" set up in Excel Table type for dynamic range growing purpose
and
The H4 formula change to :
=IFERROR(LOOKUP(9^9,Table1[price]/(LOOKUP(ROW(Table1[texture]),ROW(Table1[texture])/(Table1[texture]<>""),Table1[texture])=F4)/(Table1[length]=G4)),"")
Combining the Index() and Match() functions usually works well when using two conditions. However, you will need to fill out the entire column A with the "texture" list in order for the below formula to work.
=INDEX(<P1>, MATCH(TRUE, (<T1>=<T2>) + (<L1>=<L2>) > 1,0))
Where <P1> is your entire price column (ex. C2:C15)
Where <T1> is your entire texture column (ex. A2:A15)
Where <T2> is your texture lookup value cell
Where <L1> is your entire length column (ex. B2:B15)
Where <L2> is your length lookup value cell
Let's say that you input your texture value into cell F3, and your length value into cell F4. With the remaining columns remaining as they are in your image, you would use the following formula:
=INDEX(C2:C15, MATCH(TRUE, (A2:A15=F3) + (B2:B15=F4) > 1,0))
Now last time I had to use Index/Match I thought I had to place the formula into an array. However, the above seems to work without it.
If you notice that it's not working as expected, you can place into an array formula by clicking the cell that contains the formula, then clicking the formula box at the top. While in the formula box, simultaneously press Ctrl + Shift + Return. This should then place curly brackets around your entire formula if done properly, as such:
If you have O365 with the SEQUENCE function, you can use, for price:
=IF(G4="","",VLOOKUP(G4,INDEX($B:$C,SEQUENCE(MATCH(TRUE,ISBLANK(INDEX($B:$B,MATCH(F4,$A:$A,0)):INDEX(B:B,ROWS(B:B)-MATCH(F4,$A:$A,0))),0)-1,,MATCH(F4,$A:$A,0)),{1,2}),2,FALSE))
explanation:
get starting row:
MATCH(F4,$A:$A,0)
ending row will be the first blank row after the starting row:
MATCH(TRUE,ISBLANK(INDEX($B:$B,MATCH(F4,$A:$A,0)):INDEX(B:B,ROWS(B:B)-MATCH(F4,$A:$A,0))),0)
Construct the relevant array:
INDEX($B:$C,SEQUENCE(MATCH(TRUE,ISBLANK(INDEX($B:$B,MATCH(F4,$A:$A,0)):INDEX(B:B,ROWS(B:B)-MATCH(F4,$A:$A,0))),0)-1,,MATCH(F4,$A:$A,0)),{1,2})
The above might reduce (with wavy) to:
index(b:c,{9,10,11},{1,2}
Then it's just a matter of applying the VLOOKUP
A more understandable, but longer with more operations, formula available in O365 makes use of LET. The advantage is that one can use names which indicate what each section of the formula does.
For example:
=IF(G4="","",LET(startRow,MATCH(F4,$A:$A,0),numRows,MATCH(TRUE,ISBLANK(INDEX($B:$B,startRow):INDEX($B:$B,ROWS($B:$B)-startRow)),0)-1,
arr,INDEX($B:$C,SEQUENCE(numRows,,startRow),{1,2}),price,XLOOKUP(G4,INDEX(arr,0,1),INDEX(arr,0,2)),price))
Or, using VLOOKUP
=IF(G4="","",VLOOKUP(G4,LET(startRow,MATCH(F4,$A:$A,0),numRows,MATCH(TRUE,ISBLANK(INDEX($B:$B,startRow):INDEX($B:$B,ROWS($B:$B)-startRow)),0)-1,arr,INDEX($B:$C,SEQUENCE(numRows,,startRow),{1,2}),arr),2,FALSE))
Finally, for earlier versions of Excel, you can use this whopper where we replace the SEQUENCE function with a construct like: ROW(INDEX(A:A,firstRow):INDEX(A:A,lastRow))
=IF(G4="","",VLOOKUP(G4,INDEX($B:$C,ROW(INDEX($A:$A,MATCH(F4,$A:$A,0)):INDEX($A:$A,MATCH(F4,$A:$A,0)+MATCH(TRUE,INDEX($B:$B,MATCH(F4,$A:$A,0)):INDEX($B:$B,ROWS($B:$B))="",0)-2)),{1,2}),2,FALSE))

Index & Match to return text value

Having error in my formula.
How do i get it to display matched text output in column referencing on a column?
F11 to display A1 looking up output produce by formulas in rows above it that is not special character "-".
G11 to display B1 looking up output produce by formulas in rows above it that is not special character "-".
H11 to display B6 looking up output produce by formulas in rows above it that is not special character "-".
As shown in the picture below, formula below is my current input to reference column which produces error.
=INDEX(F5:F10,MATCH(A5:A10,A5:A10,0))
Based on Edit, you could use a formula like
=LOOKUP(2,1/(F5:F10=$A$5:$A$10),F5:F10)
Copy it across!
If there's going to only one entry and others as dash (-) then following can also be used.
=SUBSTITUTE(CONCATENATE(F5,F6,F7,F8,F9,F10),"-","")
Explanation for LOOKUP:
We simply compare values in formula column (F in this case) with values in Column A by using
(F5:F10=$A$5:$A$10) which produces results like TRUE;FALSE;FALSE;FALSE;FALSE
when these results are used to divide 1 then they're coerced to numbers (TRUE=1, FALSE=0) so the resultant array looks like 1,#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!.
We are looking in TRUE result which will be always equal to 1. So we are using a number larger than 1 i.e. 2 as LOOKUP uses binary search. Any large number can be used.
And then outer LOOKUP simply returns the matched item from passed array.
You can precisely see this by using Formula Evaluate option in the ribbon Formulas >> Formula Auditing >> Evaulate Formula.

EXCEL - Search formula with multiple criteria

Do you know any way to write a formula for vlookup/indexmatch which will look for first result other than "null" for "aaaa", and then for bbb etc?
I was trying to do that with using multiple if/offsets etc, but its not working.
Is it even possible (there can be one row with "aaa" but also 10 on even more).
The following array formula returns the first entry in column B where it is not null and also where column A has cell value aaaaa.
= IFERROR(INDEX(B1:B6,MATCH(1,(A1:A6="aaaaa")*(B1:B6<>"null"),0)),"no match")
Note this is an array formula, so you must press Ctrl+Shift+Enter on the keyboard after typing the formula rather than just pressing Enter.
To return a similar result except for bbbbb, just replace aaaaa in the above formula with bbbbb.

Excel find lower distinct value in list

I'm trying to find in a list the lowest unique value.
I tried to find out a way on google, but nothing seem to work like I want.
What i have :
John;5
Leon;7
Mark;5
Bob;3
Peter;3
Louis:4
Desired result: "4" because it's the lower unique value.
Suppose I add in the original list:
Alex;4
The new result is about to be "7" because it's the new lowest unique value.
my excel sheet :
Assuming your data is setup so that names are in column A and values are in column B so that it looks like this:
In cell D2 (or wherever you want the result), use this array formula (Note that array formulas must be confirmed with CTRLSHIFTENTER and not just ENTER):
=MIN(IF(COUNTIF(B2:B20,B2:B20)=1,B2:B20))
You'll know you've entered it as an array formula correctly because you'll see it surrounded by curly braces {=formula}in the formula bar. Do NOT add the curly braces manually.
You'll also notice that I have extra rows in there than just the used rows. Normally I'd suggest using a dynamic named range, but this works for now. So when you add the new line of Alex; 4, you get this:
And you can see the formula now has the new correct value of 7.
With data in columns A and B, in C1 enter:
=COUNTIF(B:B,B1)
and copy down. Then in another cell enter the array formula:
=MIN(IF(C:C=1,B:B))
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key.
To avoid speed problems, make the limits on the ranges as small as possible:
=MIN(IF(C1:C6=1,B1:B6))

Resources