How to enter information in one cell based on text in another cell - excel

I would like to enter information in a cell based on the text contained in a different cell. Specifically, if a cell in column A contains text that includes "insurance," "retirement," or "401K," then I want to place an "x" in its respective cell in Column B. If not, then cell B1 should be empty. The text needs to be contained within the cell, but does not need to be the exact text. E.g., an "x" would still be placed in the column next to "life insurance" or "insurance," "whole life insurance," etc.
E.g.,
Column A Column B
Life Insurance x
Securities
Retirement x
I tried to use the following formula, but am getting an error message when I do so:
IF(OR(ISNUMBER(SEARCH("insurance",A1,"retirement",A1, "401K",A1)),"x", "")
Any thoughts?

This formula should help:
=IF(OR(ISNUMBER(FIND("Insurance",A1)),ISNUMBER(FIND("Retirement",A1)),ISNUMBER(FIND("401K",A1))),"x","")
EDIT:
I came up with an array formula that I like a little better. Hope this helps:
=IF(COUNT(MATCH({"*Insurance*","*Retirement*","*401K*"},A1,0))>0,"x","")
This will require pressing CTRL + SHIFT + ENTER instead of just ENTER after putting it in the cell because it's an array formula.

Related

How to highlight cell that does not contain specific text from any column

I have a excel file with 2 excel sheet. The sheets are called first and second.
For the first sheet, it contain 1 column, animal while the other sheet, it contains 1 columns, sentence.
name of the 1st sheet: first
animal
cat
fly
deer
dog
deer
snail
name of the 2nd sheet: second
sentence
thedogpoops
thedeerismyinhouse
where is my cat
theflyis annoying
In the first sheet, if any of the animal is not contained in the second sheet, it should be highlighted. "snail" should be highlighted in animal sheet
I used search excel formula to do this. I go to conditional formatting and use a formula to determine which cells to format. I implemented the code
=NOT(ISNUMBER(SEARCH('Sheet 1'!$A:$A,$A:$A)))
The output is that the whole animals is highlighted
What I am trying to do is that if the animal is not found in any of the column, it will be highlighted. However it does not work. Can you please correct this problem?
Based on your example this should work:
=if(A3="","",if(count(search(A3,second!$A:$A))>0,":-)",":-("))
ARRAY FORMULA press SHIFT + CTRL + ENTER to enter formula
You can place that beside the animal and pull it down.
You can use conditional formatting on the list to highlight like in my case ":-(" the sad smiley or you use better visible letters for highlighting.
If you just want to highlight the "missing" animals, then delete the happy smiley from the formula.
=if(A3="","",if(count(search(A3,second!$A:$A))>0,"",":-("))
ARRAY FORMULA press SHIFT + CTRL + ENTER to enter formula
Select column A on the Animals worksheet and create a CFR based on this formula,
=isna(match("*"&$A1&"*", 'Sheet 2'!$A:$A, 0))
By 'wildcarding' the match to the value in the 'Animals' worksheet you are creating a 'contains within' criteria to any string in Sheet 2's column A like the non-case-sensitive SEARCH function.
Rather than produce a series of images on how to do it manualy, this is the VBA equivalent.
With worksheets("Animals").range("a:a")
.FormatConditions.Delete
with .FormatConditions.Add(Type:=xlExpression, Formula1:="=isna(match(char(42)&$A1&char(42), 'Sheet 2'!$A:$A, 0))")
.Interior.Color = vbred
end with
End With
When a cell contains an error like #VALUE! this is not text with those the phrase "VALUE"; not something you can (or should) search for in this way. It is a sort of placeholder showing where an error is.
To determine whether a formula or function results in an error use ISERROR or IFERROR.
For example, if you want to return Not Found if your formula produces an error, you could use:
=IFERROR(SEARCH($A:$A,'Sheet 2'!$A:$A),"Not Found")
I prefer VLOOKUP for finding matches.
For example, you could enter in cell B2 on sheet First:
=VLOOKUP("*" &A2&"*",second!$A$2:$A$5,1,FALSE)
...and then fill or copy the formula down to cell A7.
If a matching phrase is found in Second then it will show that phrase, otherwise it will produce an error.
This time using ISERROR (as well an IF) as an example, you could display whether or not there was a match by instead using this formula in cell B2 on sheet First:
=IF(ISERROR(VLOOKUP("*"&A2&"*",second!$A$2:$A$5,1,FALSE)),"No Match","Matched!")
...and then fill or copy the formula down to cell A7.
More Information:
TechOnTheNet : How to use the ISERROR Function
ExcelJet : How to use the Excel IFERROR Function

How to create Excel list from row title including COUNTIF statement?

I have created a spreadsheet with the tally function =COUNTIF(E$2:H$41," * "&$A85&" * "), which is working, but now I would like to add an additional column that lists what groups those tallies occur.
For example, say " * "&$A85&" * " is searching for the word Apple in E$2:H$41 and it was found in E17. I would want the title of that row to show. For this case Fruit from cell A17. If there were other rows in which Apple was found, say red, I would like those listed as well.
I have tried using the INDEX command but cannot get the formula to work that way.
Any help is appreciated.
You didn't say which column your title is in, but if were in column D then the formula below should work. if it's in column A then change the start to =INDEX(A2:A41.
=INDEX(A2:A41,MATCH(1,(ISNUMBER(FIND($A85,E2:E41)))+(ISNUMBER(FIND($A85,F2:F41)))+(ISNUMBER(FIND($A85,G2:G41)))+(ISNUMBER(FIND($A85,H2:H41))),0))
It's an array formula so you need to confirm with Ctrl + Shift + Enter
It's an index formula that indexes D2:D41 and then the match has a look at the 4 columns E, F, G, and H with OR (confusingly the + sign denotes or).
Because you wanted to search within the cell using *, I used ISNUMBER(FIND($A85,G2:G41)) which returns the character number if it finds the text.
To return more than 1 title
=IFERROR(INDEX($A$2:$A$41,SMALL(IF((ISNUMBER(FIND($A$85,$E$2:$E$41)))+(ISNUMBER(FIND($A$85,$F$2:$F$41)))+(ISNUMBER(FIND($A$85,$G$2:$G$41)))+(ISNUMBER(FIND($A$85,$H$2:$H$41))),ROW($A$2:$A$41)-1),ROW(1:1)),1),"")
It's also an array formula so don't forget to Ctrl + Shift + Enter to add the curly brackets.
This formula in a single cell will not return multiple results so you need to drag/copy the formula down enough cells to accommodate as many results as you think will be returned.
each formula will be the same except for the part at the end ROW(1:1:) which will change to ROW(2:2:), ROW(3:3:).
I have placed the formula in cells B85 and B86 and below but I would advise against using this formula in an area of a sheet if you are going to insert and delete rows above as this sometimes breaks the ROW(1:1:) references. I normally put a formula like this on a different sheet from the source data.

IF formula contains certain text for entire column

So for this excel file, I need to calculate a percent for one subject which has several rows. With this, I have thus come up with:
=IF(COUNT(SEARCH("b0021",B3:B14)), (SUM(T3:T14))/12, "no")
Column B Column T
b0021 1
b0021 0
...
b0025 1
However, this does not seem to work, as to search that ALL the cells contain this text (right now it looks that at least one cell contains the text, which is not what I want to do if it should be one for the subject).
Any ideas of how I can do this?
Thank you.
You need to edit your cell and press Ctrl + Shift + Enter to make it array formula
Your formula =COUNT(SEARCH("b0021",B3:B14)) would start showing result only if it's in brackets
{=COUNT(SEARCH("b0021",B3:B14))}
In other words just add { } to make it formula array or by pressing Ctrl + Shift + Enter while editing your formula
{=IF(COUNT(SEARCH("b0021",B3:B14)), (SUM(T3:T14))/12, "no")}
It looks from your formula that you would need to use =SUMIFS formula rather than what you have:
=SUMIFS(T3:T14,B3:B14,"b0021")/SUM(T3:T14)

Multiple If And Statements

I am a novice excel user so I'll explain this the best I can. I need to track Returns, Returns/Exchanges and who processed each...
Cell column A Contains employee Names
Cell column B is where return information will go
Cell column C is where exchange information will go
In B2 I want a formula that will say, if A11:A300 contains 'Ben', and F11:F300 contains 'return', then E11:E300
Does this make sense?
Thanks in advance!
I can't tell if you're attempting to "count" all instances of "Ben" and "return" and collect the total in B2, or if you want to return the value of E11:E300 in B11:B300 when the condition that each row that containing "Ben" and "return" is met.
If it's the former, the this should do it:
=SUM(($A11:$A300="Ben")*($F11:$F300="return"))
Just enter that formula into cell B2 and hold "Ctrl + Shift" while you hit "Enter." That will create an array formula that will count all instances of "Ben" and "return" for each row. You'll know you did it right if the formula is surrounded by curly braces {}. And, no, you cannot manually add them. You must use the entry combination: Ctrl + Shift + Enter.
If it's the latter, then this should do it:
=IF(AND($A11="Ben", $F11="return"),$E11,"")
You could do this more efficiently with an array formula (as specified above), but it's a bit more complicated and I don't want to confuse you since you're an admitted "novice."
Just enter that formula into cell B11 and then drag and copy it down to the remaining 299 rows. This will return the value of E11:E300 in B11:B300 as you requested in your question.
If it's something other than that, then you need to rephrase your question.

excel first word from cells in other cell

How can I extract the first word of a number of different cells and have each of the first words show together in one other cell separated by comma?
e.g. A1 shows "Firstname1 Lastname1", A2 shows "Firstname2 Lastname2", A3 shows "Firstname3 Lastname3",
I need a formula allowing me to show the following in cell D2 "Firstname1, Firstname2, Firstname3"
I found this solution, which gives me the first word of one cell and shows it in another cell but I don't know how to get the first word of a number of cells and show them all coma separated in another cell
=LEFT(A1,SEARCH(" ",A1)-1)
Excel function to get first word from sentence in other cell
Thanks!
What if instead of just three cells you have an Excel range A1:A100 which has all the names? How would you concatenate in such an instance? Will you type that long a formula?
As Jerry suggested, VBA is Apt for this. But what if you do not want to use VBA or long formulas?
See this example. I am taking 10 cells for the sake of explaining.
Let's say the data looks like this.
Now select the entire column and click on Data~~>Text To Columns
When you click finish, the output will be like this
Now in cell say E4, type this =Transpose(A1:A10). Replace A1:A10 with the actual range. However do not press the Enter key. Press the key F9. You will see that all the first names are now visible.
Simply copy that and press Esc. Now open Notepad and paste it there.
Next delete the { and the }
Next manually replace "," by , and you will get what you wanted.
=LEFT(A1,SEARCH(" ",A1)-1) &", "&LEFT(A2,SEARCH(" ",A2)-1)&", "&LEFT(A3,SEARCH(" ",A3)-1)
using your current formula, =LEFT(A1,SEARCH(" ",A1)-1), you can add the value of subsequent cells to the previous calculation, and build the comma separated values.
in B1, we have your original formula, =LEFT(A1,SEARCH(" ",A1)-1)
in B2 we concatenate the previous result, and add on the comma and the new word:
=B1 & "," & LEFT(A2,SEARCH(" ",A2)-1)
copy this to B3 (and on) and you will slowly see the full list getting created.
The last value is the one you want, so, in C1, put the formula
=OFFSET(B1,COUNTA(B:B)-1,0)
(and hide column B so it looks better)

Resources