Home

HOW TO: "If cell contains specific text display the immediate next word after it"

%3CLINGO-SUB%20id%3D%22lingo-sub-263751%22%20slang%3D%22en-US%22%3EHOW%20TO%3A%20%22If%20cell%20contains%20specific%20text%20display%20the%20immediate%20next%20word%20after%20it%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-263751%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20an%20excel%20file%20with%20each%20individual%20cell%20filled%20with%20data%20as%20it%20follows%3A%3C%2FP%3E%3CP%3E%3CSTRONG%3EAlejandro%20-%20GREEN%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3EDaniel%20-%20RED%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3ESebastian%20-%20BLUE%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20I%20have%20been%20trying%20to%20do%20is%20to%20use%20a%20formula%20to%20extract%20the%20upper%20case%20value%20thats%20after%20the%20%22-%22%20immediate%20to%20the%20specific%20name%20of%20the%20person.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAt%20the%20moment%20I%20have%20the%20formula%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%3DIF(COUNTIF(F3%3AF20%2C%22*%22%26amp%3B%22Daniel%22%26amp%3B%22*%22)%2C%22Yes%22%2C%22No%22)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhich%20would%20simply%20return%20%22Yes%22%20if%20the%20cell%20contains%20the%20name%20Daniel%2C%20what%20I%20dont%20know%20how%20to%20do%20is%20to%20replace%20the%20%22Yes%22%20for%20a%20formula%20that%20would%20give%20me%20the%20%22RED%22%20in%20return.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20know%20the%20formulas%20Left%2C%20Mid%20and%20Right%20are%20probably%20the%20way%20to%20go%20but%20since%20the%20separating%20character%20appears%203%20times%20in%20a%20single%20cell%20(it%20being%20%22-%22%20I%20THINK)%20I%20have%20no%20idea%20how%20to%20stablish%20to%20use%20only%20the%20one%20after%20the%20specific%20name%2C%20and%20return%20only%20the%20very%20first%20word%20next%20to%20it%20(RED%20in%20case%20of%20Daniel).%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20this%20I%20have%20the%20formula%3CBR%20%2F%3E%3DMID(M26%2CFIND(%22-%22%2CM26)%2B2%2C3)%3CBR%20%2F%3EWhich%20would%20give%20me%20GRE%20(3%20characters%20only%2C%20dont%20know%20how%20to%20make%20it%20dynamic%20length)%20and%20would%20only%20return%20the%20very%20first%20entry%20as%20opposed%20to%20it%20being%20the%20one%20after%20the%20specific%20name%2C%20kinda%20close%20but%20no%20luck%20yet%20%3CLI-EMOJI%20id%3D%22lia_confused-face%22%20title%3D%22%3Aconfused_face%3A%22%3E%3C%2FLI-EMOJI%3E%3CBR%20%2F%3E%3CBR%20%2F%3EIs%20this%20even%20possible%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EEdit%3A%20I%20attach%20my%20original%20file%2C%20I%20didnt%20before%20because%20the%20formula%20get%20so%20convoluted%20with%20other%20stuff%20I%20tried%20to%20keep%20it%20simple%2C%20basically%20its%20the%20formula%20on%20column%20O%20where%20i%20would%20replace%20the%20%22%3AD%22%20with%20the%20formula%20that%20im%20asking%20about.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-263751%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFunctions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-264146%22%20slang%3D%22en-US%22%3ERe%3A%20HOW%20TO%3A%20%22If%20cell%20contains%20specific%20text%20display%20the%20immediate%20next%20word%20after%20it%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-264146%22%20slang%3D%22en-US%22%3E%3CP%3EI%20still%20not%20sure%20I%20understood%20your%20logic%20and%20what%20you'd%20like%20to%20do%2C%20but%20in%20general%20you%20may%20find%20first%20the%20cell%20where%20the%20name%20with%20dash%20is%3C%2FP%3E%0A%3CPRE%3E%3DIFNA(INDEX(%24J%2426%3A%24N%2426%2CMATCH(1%2CINDEX(--ISNUMBER(SEARCH(F3%26amp%3B%22%20-%22%2C%24J%2426%3A%24N%2426))%2C1%2C0)%2C0))%2C%22%22)%3C%2FPRE%3E%0A%3CP%3Eand%20extract%20second%20part%20from%20returned%20value%3C%2FP%3E%0A%3CPRE%3E%3DIFERROR(MID(Q3%2CFIND(%22-%22%2CQ3)%2B2%2CFIND(CHAR(10)%2CQ3%2CFIND(CHAR(10)%2CQ3)%2B1)-FIND(%22-%22%2CQ3)-2)%2C%20%22N%2FA%22)%3C%2FPRE%3E%0A%3CP%3EPlease%20see%20in%20Q3%2C%20R3.%20Sure%20above%20formulas%20could%20be%20combined%20in%20one.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-263821%22%20slang%3D%22en-US%22%3ERe%3A%20HOW%20TO%3A%20%22If%20cell%20contains%20specific%20text%20display%20the%20immediate%20next%20word%20after%20it%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-263821%22%20slang%3D%22en-US%22%3E%3CP%3EEdit%3A%20now%20that%20i%20notice%20it%20never%20asks%20which%20name%20it%20is%20substracting%20from%20%3CLI-EMOJI%20id%3D%22lia_confused-face%22%20title%3D%22%3Aconfused_face%3A%22%3E%3C%2FLI-EMOJI%3E%20it%20got%20the%26nbsp%3Bfirst%20one%20instead%2C%20not%20quite%20the%20thing%20but%20sooo%20close!%3CBR%20%2F%3E%3CBR%20%2F%3EOne%20quick%20question%2C%20how%20would%20you%20make%20it%20dynamic%3F%20so%20that%20it%20uses%20the%20cell%20that%20matched%20the%20countifs%20conditional%20i%20have%20on%20column%20O%20instead%20of%20a%20hardcoded%20%22M26%22%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-263814%22%20slang%3D%22en-US%22%3ERe%3A%20HOW%20TO%3A%20%22If%20cell%20contains%20specific%20text%20display%20the%20immediate%20next%20word%20after%20it%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-263814%22%20slang%3D%22en-US%22%3E%3CP%3EIf%20only%20from%20first%20line%20(actually%20second%20in%20the%20cell%20since%2027%20is%20in%20the%20first%20line)%3C%2FP%3E%0A%3CPRE%3E%3DMID(M26%2CFIND(%22-%22%2CM26)%2B2%2CFIND(CHAR(10)%2CM26%2CFIND(CHAR(10)%2CM26)%2B1)-FIND(%22-%22%2CM26)-2)%3C%2FPRE%3E%0A%3CP%3Eand%20attached%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-263796%22%20slang%3D%22en-US%22%3ERe%3A%20HOW%20TO%3A%20%22If%20cell%20contains%20specific%20text%20display%20the%20immediate%20next%20word%20after%20it%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-263796%22%20slang%3D%22en-US%22%3Efor%20some%20reason%20this%20returns%20the%20word%20after%20the%20%22-%22%20and%20the%20first%20word%20on%20the%20next%20line%20of%20the%20same%20cell%2C%20i%20included%20a%20copy%20of%20the%20original%20file%20in%20my%20original%20comment%20now%20to%20avoid%20confusing%20everyone%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-263793%22%20slang%3D%22en-US%22%3ERe%3A%20HOW%20TO%3A%20%22If%20cell%20contains%20specific%20text%20display%20the%20immediate%20next%20word%20after%20it%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-263793%22%20slang%3D%22en-US%22%3Esorry%20i%20am%20literally%20new%20to%20this%20site%2C%20i%20attached%20the%20file%20to%20the%20original%20post%20just%20now%3CBR%20%2F%3E%3CBR%20%2F%3EBecause%20of%20my%20mistake%20the%20formula%20you%20provided%20did%20not%20match%2C%20sorry%20%3CLI-EMOJI%20id%3D%22lia_confused-face%22%20title%3D%22%3Aconfused_face%3A%22%3E%3C%2FLI-EMOJI%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-263784%22%20slang%3D%22en-US%22%3ERe%3A%20HOW%20TO%3A%20%22If%20cell%20contains%20specific%20text%20display%20the%20immediate%20next%20word%20after%20it%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-263784%22%20slang%3D%22en-US%22%3E%3CP%3EAlejandro%2C%20you%20leave%20some%20room%20for%20interpretation%20because%20you%20did%20not%20provide%20a%20sample%20file%20with%20the%20desired%20results.%3C%2FP%3E%3CP%3EMy%20guess%20woulds%20be%3A%3C%2FP%3E%3CPRE%3E%3DIF(COUNTIFS(A1%2C%22*Daniel*%22)%2CSUBSTITUTE(A1%2C%22Daniel%20-%20%22%2C%22%22)%2C%22No%22)%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-263777%22%20slang%3D%22en-US%22%3ERe%3A%20HOW%20TO%3A%20%22If%20cell%20contains%20specific%20text%20display%20the%20immediate%20next%20word%20after%20it%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-263777%22%20slang%3D%22en-US%22%3E%3CP%3EThat%20could%20be%3C%2FP%3E%0A%3CPRE%3E%3DMID(M26%2CFIND(%22-%22%2CM26)%2B2%2CFIND(%22-%22%2CM26%2CFIND(%22-%22%2CM26)%2B1)-FIND(%22-%22%2CM26)-2)%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

I have an excel file with each individual cell filled with data as it follows:

Alejandro - GREEN

Daniel - RED

Sebastian - BLUE

 

What I have been trying to do is to use a formula to extract the upper case value thats after the "-" immediate to the specific name of the person.

 

At the moment I have the formula: 

=IF(COUNTIF(F3:F20,"*"&"Daniel"&"*"),"Yes","No")

 

Which would simply return "Yes" if the cell contains the name Daniel, what I dont know how to do is to replace the "Yes" for a formula that would give me the "RED" in return.

 

I know the formulas Left, Mid and Right are probably the way to go but since the separating character appears 3 times in a single cell (it being "-" I THINK) I have no idea how to stablish to use only the one after the specific name, and return only the very first word next to it (RED in case of Daniel). 

 

For this I have the formula
=MID(M26,FIND("-",M26)+2,3)
Which would give me GRE (3 characters only, dont know how to make it dynamic length) and would only return the very first entry as opposed to it being the one after the specific name, kinda close but no luck yet :/

Is this even possible?

 

 

 

Edit: I attach my original file, I didnt before because the formula get so convoluted with other stuff I tried to keep it simple, basically its the formula on column O where i would replace the ":D" with the formula that im asking about.

7 Replies
Highlighted

That could be

=MID(M26,FIND("-",M26)+2,FIND("-",M26,FIND("-",M26)+1)-FIND("-",M26)-2)
Highlighted

Alejandro, you leave some room for interpretation because you did not provide a sample file with the desired results.

My guess woulds be:

=IF(COUNTIFS(A1,"*Daniel*"),SUBSTITUTE(A1,"Daniel - ",""),"No")
Highlighted
sorry i am literally new to this site, i attached the file to the original post just now

Because of my mistake the formula you provided did not match, sorry :/
Highlighted
for some reason this returns the word after the "-" and the first word on the next line of the same cell, i included a copy of the original file in my original comment now to avoid confusing everyone
Highlighted

If only from first line (actually second in the cell since 27 is in the first line)

=MID(M26,FIND("-",M26)+2,FIND(CHAR(10),M26,FIND(CHAR(10),M26)+1)-FIND("-",M26)-2)

and attached

 

Highlighted

Edit: now that i notice it never asks which name it is substracting from :/ it got the first one instead, not quite the thing but sooo close!

One quick question, how would you make it dynamic? so that it uses the cell that matched the countifs conditional i have on column O instead of a hardcoded "M26"?

Highlighted

I still not sure I understood your logic and what you'd like to do, but in general you may find first the cell where the name with dash is

=IFNA(INDEX($J$26:$N$26,MATCH(1,INDEX(--ISNUMBER(SEARCH(F3&" -",$J$26:$N$26)),1,0),0)),"")

and extract second part from returned value

=IFERROR(MID(Q3,FIND("-",Q3)+2,FIND(CHAR(10),Q3,FIND(CHAR(10),Q3)+1)-FIND("-",Q3)-2), "N/A")

Please see in Q3, R3. Sure above formulas could be combined in one.

 

 

Related Conversations
Word 365 svg import problem
Goupil35000 in Office 365 on
0 Replies
Page numbers won't start at 1
jamieschwenger in Office for Mac on
5 Replies
Deleting Sections in Word for the Mac
Bob_Irvine in Office for Mac on
0 Replies
Protected Word forms for assignments
Kylie66 in Word on
0 Replies