extracting substring after specific word in excel - excel-formula

How to extract text string after specific word or selected word in excel
ishue type: some text.
Solution: NA#
Remarks: NA
I want to extract text after solution:

If you dont want to include the word solution in your output you can use the following formula, if your text value is in cell A1
=MID(A1,(FIND("Solution:",A1)+10),LEN(A1))
The +10 will remove the value Solution: from the export.
If you want to include the word solution you can use
=MID(A1,(FIND("Solution:",A1)),LEN(A1))
The find element will find the word you are looking for, while the mid element will look for the element within the string. Finally the len function will extract everything after the selected word, to the length of the original string

Related

How to extract a string from 2 strings in Excel counting from the second string instead from the default left side

Here's a string:
Sample text here, EXTRACTTHIS(), and ignore the rest.
I want EXTRACTTHIS() to be extracted, so I used this simple formula:
=MID(LEFT(A5,FIND("()",A5)+1),FIND(" ",A5)+1,LEN(A5))
However I got this:
text here, EXTRACTTHIS()
Of course I can just mod it to be =MID(LEFT(A6,FIND("()",A6)+1),FIND(" ",A6)+10,LEN(A6)) to get EXTRACTTHIS().
But I want this formula to work with the whole column such as the following example:
I give you the next sample: WHAT_IF_THE_STRING_LENGTH_IS_DIFFERENT(), what to do?
The problem is that Excel counts from the left side of the parent string. I want Excel to count the 1st substring ' ' from the right side of the 2nd substring which is (). Is it doable?
In your examples, it appears you want to extract the substring that ends with ().
If that is not what you mean, please be more specific.
Try: =TRIM(RIGHT(SUBSTITUTE(LEFT(A1,FIND("()",A1)+1)," ",REPT(" ",99)),99))
Find the location of the (): FIND("()",A1)
Extract the portion of the string up to and including the ()
LEFT(A1, ... +1) => Sample text here, EXTRACTTHIS()
Then extract the last space separated substring from that
TRIM(RIGHT(SUBSTITUTE(... , " ",REPT(" ",99)),99))

How do I make a cell return a value based on the characters.?

I have a cell that I want to use and IF statement to tell return information based on characters in the cell. I.E the cell has =M=WRFY, I want the statement to give me a start time based on the day within. I used this formula for the first set and it worked but for the next day it fails.
=IF(LEFT(I44,1)="S",H44,"")
I've tried entering the 2 where the 1 is to make it look at character 2 but its not working. Help!!
With Mid or Left or Rightyou need to specify a position in the string, which isn't a big deal in this case since it's not changing. Either way I prefer to use FIND, which returns either a number (the position that the string1 was found in string2, or else an Error if it's not found.
The location is irrelevant in this case so this just checks if there's an error. If so, it wasn't found (and we get a "" blank string); if not, it was found (and returns the value of cell H44).
=IF(ISERROR(FIND("S",$E6)),"",H44)
You said something about it only working for a few cells. If you're copying the formula to other cells but want to keep on referring to column "E" then putting a $ in front of E keeps that letter "locked in" whereever you copy it.
(Reference)
Splitting up a cell
A combination of the Find, Left, Right, and Len functions will handle many common tasks like splitting a single text value 2:30 PM-3:30 PM into two cells.
We already know that Find will locate one string inside another, like FIND("-",A2) would return 8 in this example. And, we know that Left returns characters from the left side of a string.
We don't want the first 8 because that would include the "-" that was "found". So, we'll subtract one. Assuming your text to split is in cell A2, this place this formula where you want the left part of the string:
=LEFT(A2,FIND("-",A2)-1)
and we know Right returns the right-side number of characters we specify. Len will tell us the total length of the string. Therefore, total length minus the left part that we don't want in this part...
Place this formula where you want to right part of the string:
=RIGHT(A2,LEN(A2)-FIND("-",A2))
Basic text functions worth learning
A little bit of homework for you. Once you start practicing with functions they will make a lot more sense, and "nesting" (combining) them will become second nature! :-)
CHAR : Returns the character specified by the code number
CLEAN : Removes all nonprintable characters from text
CODE : Returns a numeric code for the first character in a text string
CONCATENATE : Joins several text items into one text item
FIND : Finds one text value within another (case-sensitive)
LEFT : Returns the leftmost characters from a text value
LEN : Returns the number of characters in a text string
LOWER : Converts text to lowercase
MID : Returns a specific number of characters from a text string starting at the position you specify
PROPER : Capitalizes the first letter in each word of a text value
REPLACE : Replaces characters within text
REPT : Repeats text a given number of times
RIGHT : Returns the rightmost characters from a text value
SEARCH : Finds one text value within another (not case-sensitive)
SUBSTITUTE : Substitutes new text for old text in a text string
TEXT : Formats a number and converts it to text
TRIM : Removes spaces from text
UPPER : Converts text to uppercase
VALUE : Converts a text argument to a number
(Source)
Also valuable: Excel Functions Listed By Category

Excel Index Match with text string

enter image description hereI am trying to write a formula that will allow me to return a value based on it being matched with a short text string that is contained in a longer text string. Please see below. I would like the "Unit Time" column in the second table to retrieve that corresponding value from the first table by matching the shorter text string in the product column of the first table in the longer product name in the second table. Any thoughts would be appreciated.
Thanks
excel
If the product will always be XX-XX then you can use:
=INDEX(B:B,MATCH(Left(D2,5),A:A,0))
If the product can be more than 2 characters around the dash, then you'll have to use the Find() formula to get the position of the end of the product in col D instead of Left().
To account for row 4 as Scott pointed out:
=INDEX(B:B,MATCH(LEFT(D2,FIND("-",D2,4)-1),A:A,0))
This will find the second dash in the string and use the variable length for the Left() function.

Find word plus additional characters in Excel cell

I have an excel sheet with text in a cell - I'd like to extract the specific text and an additional 5 characters alongside it.
For example:
Cell A1 contains the text - 'Here is the cell for widget 1A1A and its content'. I'd like to find any cell that contains the word 'widget' and extract that and the following 5 characters (including space). So the result would be 'Widget 1A1A'.
This is quite straightforward. Use the SEARCH command to find the word "widget" (FIND is the same but case-sensitive):
=SEARCH("widget",A1)
This gives you the character number in the cell where the match is found [if no match is found it returns "#N/A".
Then match this with the MID function to pull in the text "Widget" + the following 5 characters, as follows:
=MID(A1,SEARCH("widget",A1), LEN("widget") + 5)

Function to count second word characters in cell

I need to find the character count of last/second word in Excel cell.
Example: John Smith - I need a function, that would calculate the length of the word Smith. In that case, that would be 5.
Here you go : =IFERROR(LEN(RIGHT(A1,LEN(A1)-FIND("☃",SUBSTITUTE(A1," ","☃",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))));LEN(A1))
My response is inspired from the solution of m4573r in this post
You mention it's the second/last word in a cell you're trying to count. If it's always a two word string, so the second word is always also the last word, you can use a very simple formula of
=LEN(MID(A1,FIND(" ",A1)+1,256))
This will count how many characters there are after the first space.

Resources