How to extract text from excel cell - excel

having this data in excel cell
kerass(xcvbn=2, abcdefg_iD='510863005')
having 100000 of records so, how to extract id number using excel formula from that excel sheet
Thanks in advance

Assuming your value is in cell A2. Here is a formula to be inserted
=SUBSTITUTE(RIGHT(A2,LEN(A2)-SEARCH("_iD='",A2)-4),"')","")
This means:
Search for "_iD='"
Once found, subtract the length of "_iD='" of that location (hence the 4)
Use the total length of the string, subtracted with location and 4, in order to find where the actual identifier begins
Take the right part of the string, only the part behind "_id='...'" remains
In that part, replace "')" by an empty string (otherwise you get "...005')"

Alternative answer:
=MID(A1,FIND("'",A1)+1,9)
The find formula finds the first "'" starting position
Assuming all the ID's are 9 digits, the MID formula uses the starting pos. from find and takes the following 9 digits.

So assuming your text is in cell A2, and that the id is the first 9 characters of the last 11 then this is the simplest I can think of:
=LEFT(RIGHT(A2,11),9)
But if extra characters get added or the ID changes length.
Does have the benefit of being minimalist on functions and low volativity.

Related

Excel IF Function with LEFT Function criteria

I am using GOOGLE SHEETS and I am trying to manipulate received data in the following way:
In column A, I have a number. In column B I have a department. In column C I change the number to concatenate with the first letter of column B's value ONLY IF the number starts with 36. If it doesn't it simply returns the new number as the original number. I had to use the SEARCH function because IF LEFT
is not working here, so the issue is if changes the number wherever it finds a 36, instead of just those numbers starting with 36. Any assistance will be highly appreciated.
This formula is used in column C :
=IFERROR(IF(SEARCH("36",A2),CONCATENATE(A2,LEFT(B2,1)),A2),A2)
Here is the IF LEFT function that I've tried :
=IFERROR(IF(LEFT(A2,2) = "36",CONCATENATE(A2,LEFT(B2,1)),A2),A2)
(If errors occur or the old number doesn't start with 36 the new number should remain the original)
Thanks in advance
Edit: Changed LEFT function to correct ranges, forgot to edit this in initially when asking the question.
Give this a try:
=IF(LEFT(A2,2)="36",A2 & LEFT(B2,1),A2)
This approach does not use IFERROR() or CONCATENATE().It assumes your version of Excel uses the English version of the function names and uses , as the argument separator.
=IF(LEFT(A2,2)="36",CONCATENATE(A2,LEFT(B2,1)),A2)
=A2 & LEFT(B2, LEFT(A2, 2)="36")
This is a 'golfed' answer: made as short as possible (although, I have left the spaces in for readability)
If the first 2 characters of cell A2 are "36", then LEFT(A2, 2)="36" will be True. Otherwise, LEFT(A2, 2)="36" will be False.
Excel will treat True and False as 1 and 0 - so, the LEFT(B2, LEFT(A2, 2)="36") will take either the first character from cell B2, or no characters from cell B2, and add that to the end of the value from cell A2.

Total occurrences of a single digit from a string of digits across a range of cells in a column

We need to count how many occurrences of each number are in a cell over a range of cells in the same column and output a tally of the totals for each number. See the attached picture and the desired output in the column next to it. We tried other formulas found online in both excel and open office with no results.
letter Count
Working Count
Try the following formula in D1:
=LEN(TEXTJOIN("",TRUE,A:A,"#"))-LEN(SUBSTITUTE(TEXTJOIN("",TRUE,A:A,"#"),C1,""))
and populate down.
(you will need 2016 or later for TEXTJOIN)
Option 1
Single array formula (ctrl+shift+enter !) which will work for strings with a maximum length of [5] alphanumeric characters (but you can easily modify the formula by adding a few numbers in the hard-coded array constant {1,2,3,4,5}):
{=SUM(N(MID($A$1:$A$500,{1,2,3,4,5},1)=TEXT(C3,"#")))}
You can add some further trickery to let Excel define the array constant, so the formula will work for any length of the string of digits :
{=SUM(N(MID($A$1:$A$500,
COLUMN(INDIRECT("A1:"&CHAR(65+MAX(LEN($A$1:$A$500)))&"1"))
,1)=TEXT(C3,"#")))}
The part in the middle (COLUMN()) creates the {1,2,3,4,5} array. You might have seen other versions of this formula, without the CHAR, which I use to create a reference to e.g. cell E1 (knowing that 65 is the code for "A").
.
Option 2
This array formula (ctrl+shift+enter !) works in all Excel versions, but is not very "elegant" as you have to repeat the key part of the formula as many times as the maximum digits you have in your cells (this example is for max 3 characters):
{=SUM(
N(MID($A$1:$A$500;1;1)=TEXT(C3;"#"))+
N(MID($A$1:$A$500;2;1)=TEXT(C3;"#"))+
N(MID($A$1:$A$500;3;1)=TEXT(C3;"#")) )}
The character you are counting is in C3. This will work for numbers and letters. If you can have five alphanumeric characters, you have to add two more N(...) parts, and replace the second parameter of the MID function with 4 and 5 respectively.

How to get the starting cell and ending cell address of a specific matching value?

I need to find the starting cell number and the ending cell number of a specific value. For example if I have this excel sheet:
Here, I when I search for “10:” in the formula, I should get:
A1:A5
For example there’s this formula =COUNTIF(range, text) using this formula I can count the number of times that certain text is being repeated. Now I need a formula where when I enter a text, it should tell me the starting cell number and the ending cell number.
I hope I’m clear. Is this possible?
You need =iferror("A"&MATCH("10*",A:A,0) & ":A"&MATCH("10*",A:A),"") if you were searching for things that begin with 10. You can change 10 to a cell reference so long as you & "*" onto that.
The first MATCH piece gives the first matching row number in the range (which since I am looking at the whole column is the row number) and the second gives the last that is <= (in our case = because we found a first that is =). If we find nothing, the iferror handles that and returns blank for the whole thing.
The above is assuming column A is formatted as text (and sorted -- it is not meant to handle if the matching entries were in a1:a3 and then there was another in A7).

Auto increment after concatenating 3 strings

Problem: I need a formula to automatically increment when dragging down. Since the 3 strings are joined by concatenating, it doesn't seem to work.
=CONCATENATE("Sheet2!", SUBSTITUTE(ADDRESS(1,MATCH("String to Search For", Sheet2!$13:$13,0),4),1,""),"17")
String 1 is a separate sheet reference (Sheet2!)
String 2 is the column number converted to column letter where string to be searched is found using MATCH, ADDRESS, and SUBSTITUTE. In this case it was column 2 converted to B.
String 3 is the row number that I need information from IF string searched is found
After concatenating these, I need to drag it down 5000 rows and increment String 3 (the row number) but because the reference is concatenated, it will not increment. I've tried everything! Please help!
Try adding a ROWS function, e.g. if you put the first formula in Z2 use this version copied down
=CONCATENATE("Sheet2!", SUBSTITUTE(ADDRESS(1,MATCH("String to Search For", Sheet2!$13:$13,0),4),1,""),"17"+ROWS(Z$2:Z2)-1)
change depending on actual start cell
ROWS function, used this way, will increment by 1 each row and is more "robust" than alternatives using ROW for example
Assuming your formula is in row 2, you could do this:
=CONCATENATE("Sheet2!", SUBSTITUTE(ADDRESS(1,MATCH("String to Search For", Sheet2!$13:$13,0),4),1,""),text(row()+15,"#"))
If your formulas starts on a different row, just change the 15 as needed.

excel functions find pattern of a string in a cell

I have personal ID's in reports I have to find in one cell. Too bad the string in the cell which hides this ID can be anything, the ID can be at the beginning, the end, anywhere, but it is there.
The only thing I know is the pattern "space,letter,letter,number,number,number,number,number,number,space". Jike DB544345
I was looking for the correct word for this "mask", but couldn't find an answer. Thank you for your help.
As the comments are numerous I have created a minimal example that might represent what the OP is dealing with:
A1: 123456789 DB544345 asdfg asdfghjk
A2: creating dummy data is a DB544345 pain
A3: DB5443456 and soething else
parsed a copy of that in ColumnB with Text To Columns (with space as the delimiter) then applied:
=IFERROR(IF(AND(LEN(B1)=8,CODE(LEFT(B1))>64,CODE(LEFT(B1))<91,CODE(MID(B1,2,1))>64,CODE(MID(B1,2,1))<91,ISNUMBER(RIGHT(B1,6)*1),RIGHT(B1,6)*1>99999),B1,""),"")
to K1, copied this across to P1 and then K1:P1 down.
A concise "built-in function only" solution to a problem such as this requires a bit of tinkering as many attempts will dead-end or need workarounds due to deficiencies and quirks in the built-in Excel formulas. I much prefer single cell formulas because they minimally affect the general spreadsheet structure. However, due to the limitations listed above, complex single cell solutions often come at the cost of being rather long and cumbersome (this answer is somehow still only two lines on my formula bar in Excel). I came back to your question and cobbled together a formula that can (as far as I have tested) extract the first occurrence of this pattern with a single cell formula. This is an array formula (Ctrl+Shift+Enter instead of Enter) that assumes your data is in A2. This rough formula returns the first 8 characters if no match is found and throws #REF if the string is shorter than 10 characters.
=MID(A2,MIN(IF(MID(A2,ROW(INDIRECT("A1:A"&(LEN(A2)-9))),1)=" ",IF(MID(A2,ROW(INDIRECT("A1:A"&(LEN(A2)-9)))+9,1)=" ",IF(CODE(MID(A2,ROW(INDIRECT("A1:A"&(LEN(A2)-9)))+1,1))>64,IF(CODE(MID(A2,ROW(INDIRECT("A1:A"&(LEN(A2)-9)))+1,1))<91,IF(CODE(MID(A2,ROW(INDIRECT("A1:A"&(LEN(A2)-9)))+2,1))>64,IF(CODE(MID(A2,ROW(INDIRECT("A1:A"&(LEN(A2)-9)))+2,1))<91,IF(IFERROR(MID(A2,ROW(INDIRECT("A1:A"&(LEN(A2)-9)))+3,6)*1>99999,FALSE),ROW(INDIRECT("A1:A"&(LEN(A2)-9)))))))))))+1,8)
Let me try to break this down at least on a high level. We are splitting the main text into every possible ten character chunk so that we can test each one using the suggestion of #pnuts to verify the Unicode values of the first two characters and run an ISNUMBER check on the rest of the string. This first block recurs throughout my formula. It generates a list of numbers from 1 to n-9 where n is the length of our main text string.
ROW(INDIRECT("A1:A"&(LEN(A2)-9)))
Let's assume our string is 40 characters long and replace the above formula with {1...31}. Using this number sequence generation we can check if characters 1 to 31 are spaces:
IF(MID(A2,{1...31},1)=" "
Then we can check if characters 10 to 40 are spaces:
IF(MID(A2,{1...31}+9,1)=" "
Then we can check if characters 2 to 32 are capital letters:
IF(CODE(MID(A2,ROW(INDIRECT("A1:A"&(LEN(A2)-9)))+1,1))>64,
IF(CODE(MID(A2,ROW(INDIRECT("A1:A"&(LEN(A2)-9)))+1,1))<91
Then we can check if characters 3 to 33 are capital letters:
IF(CODE(MID(A2,ROW(INDIRECT("A1:A"&(LEN(A2)-9)))+2,1))>64,
IF(CODE(MID(A2,ROW(INDIRECT("A1:A"&(LEN(A2)-9)))+2,1))<91
Then we can check if the strings of characters 4 to 9, 5 to 10, ..., 33 to 38, 34 to 39 are six-digit numbers:
IF(IFERROR(MID(A2,ROW(INDIRECT("A1:A"&(LEN(A2)-9)))+3,6)*1>99999,FALSE)
If all conditions are TRUE, that 10 digit chunk test will return the index of its first character in the string via another instance of the original array {1...31}. Otherwise it returns nothing. We take the Min of all return indexes and then use the Mid function to grab the 8 digit string determined by the aforementioned minimum index:
=MID(A2,MIN(matching index list)+1,8)
I think this will work, if we assume that the SPACE at the beginning and end are merely to differentiate the ID from the rest of the string; hence would not be present if the ID were at the beginning or end of the string. This formula is case insensitive. If case sensitivity is required, we could do character code comparisons.
=LOOKUP(2,1/((LEFT(myArr,2)>="AA")*(LEFT(myArr,2)<="ZZ")*(LEN(myArr)=8)*ISNUMBER(-RIGHT(myArr,6))),myArr)
Where myArr refers to:
=TRIM(MID(SUBSTITUTE(TRIM(Sheet2!A1)," ",REPT(" ",99)),(ROW(INDIRECT("1:10"))-1)*99+1,99))
If myArr is initially defined with the cursor in B1, referring to A1 as shown, it will adjust to refer to the cell one column to the left of the cell in which the Name appears.
The 10 in 1:10 is the maximum number of words in the string -- can be adjusted if required.

Resources