Excel - pick specific characters from a string after a number - excel

I have a list of strings where I want to split the numbers and alphabets part. For e.g. in cell A1 I have "FNN-12345 - Sample Text - 2016_AA1.1" (without the quotes ""). I want to split it to get just "Sample Text - 2016_AA1.1".
Appreciate any guidance on the formula.
Cheers.

This is the universal solution, no matter what the first alphanumeric string is:
=RIGHT(A1,LEN(A1)-FIND(" - ",A1)-2)
It finds the first occurence of the string " - " and keeps only the part after that string.

You can use the functions to manipulate strings of characters in Excel like Left, Right or Mid to get the desired result in combination with a Lenghth function.
As such for you result you could try :
=RIGHT(A1, LEN(A1) - LEN("FNN-12345 - "))
This formula would take the length of the entire cell and remove the FNN-12345 - part. Of course you can add a column which contain the desired elements to be removed.

If the text which you want to select begin always on the position 13 (as in your example), use the formula
=RIGHT(A1,LEN(A2)-12)
(supposing your original text is in the cell A1).
If you recognize the start of text by the pattern " - ", use the formula
=RIGHT(A3,LEN(A3) -FIND(" - ",A4)-LEN(" - ")+ 1)

Related

How to extract a string from a cell from right to left using a specific character that occurs more than once?

Normally I would just use the RIGHT function in excel to split it by finding a specific character such as / and outputting the string that I want.
However, I am finding trouble extracting THISSTRING.txt from d/aaa/THISSTRING.txt. With only one instance of / I would just use a function such as =RIGHT(B17,LEN(B17) - FIND("/",B17))
Here's one way to get the rightmost:
=TRIM(RIGHT(SUBSTITUTE(A1,"/",REPT(" ",99)),99))
Objective: To return the rightmost sub-string from a target string after the last occurrence of a character which appears several times within the target string.
This formula:
=TRIM(RIGHT(SUBSTITUTE(A1,"/",REPT(" ",99)),99))
Provides the correct result under the following conditions:
The sub-string to retrieve does not have more than 99 characters.
The sub-string to retrieve does not contain more than one space character together.
Example: To retrieve a sub-string which is 123 characters long and contains the following characters 1 ABC XXX 123 XYZ.
Point 1 is easily solved by working with the length of the string instead of a fixed number:
=TRIM(RIGHT(SUBSTITUTE(A1,"/",REPT(" ",LEN(A1))), LEN(A1)))
However point 2 can't be overcome with the referred formula.
Proposed solution: The following formula returns the correct result regardless of the conditions mentioned above:
=RIGHT(A1, LEN(A1) - FIND( CHAR(12),
SUBSTITUTE(A1, "/", CHAR(12), LEN(A1) - LEN( SUBSTITUTE(A1, "/", "" )))))
Note: I used non-printable character 12 which is very unlikely to be found in excel, change as required.
Here's another way.....
=REPLACE(B17,1,LOOKUP(2^15,FIND("/",B17,ROW(INDIRECT("1:"&LEN(B17))))),"")
FIND generates an array of values, indicating the first position of a "/" in B17, but with the start point incrementing by 1 each time, which means that the last numeric value in that array is the positon of the last "/".
LOOKUP extracts that value from the array and we can use it in REPLACE function to replace all characters before and at that position with nothing, just leaving you with all characters after the last "/"
You'll get an error if there is no "/" in B17

Find first and second match of a list in Excel

I have text cells in column and i have a list of words, i need to get the first and second match of text cell within this list of word using formula without vba.
here is an example of the result
If your text cells start in A2, then:
First Match B2: =IFERROR(MID($A2,AGGREGATE(15,6,SEARCH(LIST,$A2),COLUMNS($A:A)),FIND(" ",$A2&" ",AGGREGATE(15,6,SEARCH(LIST,$A2),COLUMNS($A:A)))-AGGREGATE(15,6,SEARCH(LIST,$A2),COLUMNS($A:A))),"")
and fill right one cell to get the 2nd Match. Then fill down as far as needed.
EDIT: The OP has added an additional requirement having to do with excluding words within words, eg do NOT find also if the word is Calso; and also do not return punctuation.
Although cumbersome in formulas, this can be handling by
- Replacing all of the punctuation with space
- Adding a space at the beginning and end of the sentence
- Adding a space at the beginning and end of each word in LIST
- adjusting the formula to not return the extra space.
The above can be done most simply by modifying the defined name LIST and also by using a defined name for a formula to do the punctuation replacement and space prefix and suffix.
Given the example above, we redefine LIST
LIST refers to: =" " & Sheet1!$F$2:$F$6 & " "
and, with some cell in Row 2 selected, we define theSentence
theSentence refers to: =" " & TRIM(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(Sheet1!$A10,","," "),"'"," "),"."," "),"!"," "))& " "
That particular definition will remove comma, apostrophe, period and exclamation point. If you need to remove other punctuation, you can just nest more SUBSTITUTE's
And we make some changes in the formula in B2:
B2: =IFERROR(MID(theSentence,1+AGGREGATE(15,6,SEARCH(LIST,theSentence),COLUMNS($A:A)),FIND(" ",theSentence,1+AGGREGATE(15,6,SEARCH(LIST,theSentence),COLUMNS($A:A)))-AGGREGATE(15,6,SEARCH(LIST,theSentence),COLUMNS($A:A))-1),"")
This is the second interpretation of the question (find the first and second match in the list of a string anywhere in the text).
=IFERROR(INDEX($F$2:$F$6,SMALL(IF(ISNUMBER(FIND(" "&$F$2:$F$6&" "," "&$A2&" ")),ROW($F$2:$F$6)-ROW($F$1)),COLUMNS($A1:A1))),"")
Note that this is an array formula and must be entered with CtrlShiftEnter

How to extract parsed data from once cell to another

Given a spreadsheet cell containing a string that consists of a hyphenated series of character segments, I need to extract the last segment.
For example, consider column A containing data strings like XX-XXX-X-XX-XX-G10, where X denotes any character. What formula would I need to place in column B to get G10 as a result?
A B
1 XX-XXX-X-XX-XX-G10 G10
I'm looking for a formula that could work in in Libre Office Calc, Open Office Calc, MS Excel, or Google Sheets.
Another possibility in LO Calc is to use the general purpose regular expression macro shown here: https://superuser.com/a/1072196/541756. Then the cell formula would be similar to JPV's answer:
=REFIND(A1,"([^-]+$)")
If you are using google sheets, regexextract would be possible too:
=REGEXEXTRACT(A1, "[^-]+$")
In LibreOffice Calc and OpenOffice Calc, you can use a regular expression to determine the position of the text after the last - character:
=SEARCH("-[:alnum:]+$";A1)
will return 15 if A1 contains XX-XXX-X-XX-XX-G10.
Now, you can use this value to get the text "behind" that position, using the RIGHT() function:
=RIGHT(A1;LEN(A1)-SEARCH("-[:alnum:]+$";A1))
Split up on multiple lines:
=RIGHT( ' return text beginning from the right...
A1; ' of cell A1 ...
LEN(A1) ' start at lenght(A1) = 18
- ' minus ...
SEARCH( ' position ...
"-[:alnum:]+$" ' of last "-" ...
;A1 ' in cell A1 = 15 ==> last three characters
)
)
It appears that you want the characters that appear at the end of a string, to the right of the last instance of a hyphen character, "-".
This formula, adapted from here, works in Excel, *Calc & Google Sheets:
=TRIM(RIGHT(SUBSTITUTE(A1,"-",REPT(" ",LEN(A1))),LEN(A1)))
Explanation:
SUBSTITUTE(A1,"-",new_string) will find each hyphen ("-") in the original string from cell A1 and replace it with a new_string.
REPT(" ",LEN(A1)) is a string of repeated space characters (" "), the same length as the original string in cell A1.
TRIM(RIGHT(string,count)) will get the right-most count characters, and trim off leading and trailing spaces. Since the string was previously padded out by replacing hyphens with spaces, and count is the same LEN(A1) used for that padding, the last count characters consists of a bunch of spaces followed by whatever followed the last hyphen!
In Google Sheets, an alternative approach is to use the SPLIT function to break the value from column A into an array, then select the last element. (Excel-VBA has a split() function, so you could make this work in Excel by writing VBA code to provide it as a custom function.)
=INDEX(SPLIT(A1,"-"),0,COUNTA(SPLIT(A1,"-")))
I found simply solution:
=RIGHT(A1;3)
that gives me G10 as the result too! It works because COL A always have 3 chars at the end!

Excel find text value in string

I have a string such as K68272CAA6A1
And need to do that, formula will pass the first character (I mean string will be 68272CAA6A1 in mind) and formula will find the first text character. And cell value will be 7. Because first text character is "C" and it's the 7th character of my string (include "K" character).
And after that I'll split rest of them. But I'm confused about this issue.
If I understand you correctly, you are looking for the position of the 2nd letter in your string. That number is given by the following array-entered formula.
To enter an array formula, hold down ctrl+shift while hitting Enter. If you do this correctly, in the Formula Bar you will see braces {...} around the formula:
=MATCH(FALSE,ISNUMBER(MID(A1,ROW(INDIRECT("2:99")),1)/1),0)+1
The 99 just needs to be some number larger than the length of your longest string.
If I understood you correctly, a formula that implements this functionality (assuming cell A1 = K68272CAA6A1 and B1 = K) would be:
=FIND(RIGHT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(RIGHT(A1,LEN(A1)-FIND(B1,A1)),"1",""),"2",""),"3",""),"4",""),"5",""),"6",""),"7",""),"8",""),"9",""),1),RIGHT(A1,LEN(A1)-FIND(B1,A1)))-1
The long sequence of substitute is there to remove the numbers (I couldn't find a specific formula to remove them).
This gigantic formula for your example would simply give the answer 6.
To get the strings separated as you want all you need to do is =LEFT(A1,D1) supposing the long formula is on D1 and =RIGHT(A1,D1), which in your example would yield respectively K68272 and CAA6A1

I want to delete first characters in a cell?

I want to delete first characters in a cell and show it in another cell.
I have A1 - 1900: (1873, 'asd#asd.com
I want to show B1 - asd#asd.com
You can use the RIGHT function to 'keep' a number of characters:
=RIGHT(A1, LEN(A1)-B1)
Will chop off B1 characters of the content of cell A1 (in this case, B1 should contain 14, but you can make it a calculation, too)
If you have always a quote before your email, just select you column, go to Data / convert and use "'" as separator
If the apostrophe precede every e-mail address then this formula can be used in column B.
=MID(A1,FIND("'",A1)+1,LEN(A1))
The find function returns the first occurrence of the apostrophe.
The Mid function extracts the text after the apostrophe.

Resources