how to extract 10 digit number from column excel - excel

I have column which consists of text including 13 digit number. How Can I keep 10 digit number and delete all other text?
Please help me I am new to excel..
thanks in advance
Edited:
Cell Format
[6/11/2013 3:26:37 PM] 1234503776599, ksdfl 038ddf63Ksdf)
[6/12/2013 3:26:37 PM] 0234503664599, ksdfadssdfl 038ddf6dfsd3Ksdf)
[6/13/2013 3:26:37 PM] 7234503666099, 45sdsdfadssdfl 03845ddf6dfsd3Ksdf)
Here, In second column I want to keep 13 digit and delete all text after that 13 digit.

Is the number always at the beginning of the cell? If so you can use =LEFT(cell_ref, 10) to extract the first 10 characters, which in this case are numbers and will be treated as such by the spreadsheet.

I'm guessing you will need something like this
=MID(A1,32,FIND(",",A1,32) -32)
MID will get text from the middle of a string
FIND will get the location of the first comma

Thinking that the 13 digit number is in the middle of the string, with 9 spaces to the left and a comma to the right we can use the following formula in a separate cell:
=MID(A1,LEN(LEFT(A1,FIND("]",A1)+1))+9,13)
The LEN function determines the length of the part up to and including ] (big bracket). Then the number 9 is added to include nine spaces. Then the number 13 is the length of the 13 digit number. All these are used as parameters for the MID function.
After you get the result just drag down using the autofill handle to get the mid 13 digit number for all the rows.

=LOOKUP(10^11,MID(A1,ROW(INDIRECT("1:"&LEN(A1)-9)),11)+0)
This works for me.

To extract 6 continuous numeric digits, use the below code:
=LOOKUP(10^6,MID(A1,ROW(INDIRECT("1:"&LEN(A1)-5)),6)+0)
Replace 6 in the above code with the number of digits that are required to be extracted.

Related

Find the Position of a Four Digit Number in Text String. (Excel)

20/11/2022 12:00:52 2 X 15.95 15.95 USD 57 5 689 5 689 1 4111 0 Amazing Lego Team
I need to get the position of No 4111 in the above text string, As an excel beginner any help will be greatly appreciated. Thanks.
All of the Text Strings will have a 4 digit number like 4111 which i have to get the position for.
Have tried using this formula to get four digit number in another column, LOOKUP(10^15,MID(A1,ROW(INDIRECT("1:"&LEN(A1))),5)+0) but I am looking to get position instead.
I have tried using lookup but I could only go so far as a beginner.
Use the formula you provided =LOOKUP(10^15,MID(A1,ROW(INDIRECT("1:"&LEN(A1))),5)+0) to identify the number, and use FIND to get the position of the number.
Cell A1="20/11/2022 12:00:52 2 X 15.95 15.95 USD 57 5 689 5 689 1 4111 0 Amazing Lego Team"
=FIND(LOOKUP(10^15,MID(A1,ROW(INDIRECT("1:"&LEN(A1))),5)+0),A1)
=58
This looks to be in a space (or some other character) delimited text string. If you have a bunch of rows of data like this, use the Text to Columns feature on the Data tab. Use the Delimited option and then click the check box next to space (or other if it's something custom not in the available options) and Excel will split the data into columns for you.
For your string example, if you know that your 4 digit is started 58 char from the beginning of the string, use =MID(A1,58,4) A1 is the cell with your string.
MID function returns a specific number of characters from a text string, starting at the position you specify, based on the number of characters you specify.
=LET(t,TEXTSPLIT(A1,," "),
FIND(FILTER(t,(LEN(t)=4)*(ISNUMBER(--(t)))),A1))
It splits the string at every space and filters the result for being of length of 4 characters and not being an error if converted to number.

Extract 9 last number from a number of 14 digit

One of my Excel column of my board have to store numbers of 9 digits.
I'm looking for a solution to keep only the 9 last digits of any bigger number past in this specific column. It's only entire number.
Also if after formatting the number it appear that the number starts with 0 the 0 have to be kept. Is there another solution than adding an '0 at first ?
Here is what I already done : (i is the row number / Range01 is Range("A14:O400"))
If Len(Range01.Cells(i,5).value) = 9 Then
Range01.Cells(i,5).Interior.color = vbGreen
ElseIf Len(Range01.Cells(i,5).value) = 8 Then
Range01.Cells(i,5).value = "'0" & Range01.Cells(i,5).value
ElseIf Len(Range01.Cells(i,5).value) > 9 Then
????
Else
Range01.Cells(i,5).Interior.color = vbRed
End If
Thanks for the help.
The simplest way to get the last nine numbers of an integer is:
=MOD(A1,1000000000)
(For your information, that's one billion, a one with nine zeroes.)
If you're interested in showing a number with leading zeroes, you can alter the cell formatting as follows: (the format simply contains nine zeroes)
If you're interested in keeping the zeroes, you might need to use your number as a string, and precede it with a good number of repeated zeroes, something like:
=REPT("0",9-LEN(F8))&F8
Take the length of your number (which gets automatically converted into a string)
Subtract that from 9 (so you know how many zeroes you need)
Create a string, consisting of that number of zeroes
Add your number behind it, using basic concatenation.
You can simply use the math operator of modulus. If you want the last 9 digit you can write:
n % 10000000000
Where n is the number in the column.
In VBA:
MOD(n,1000000000)

Data validation on number of numerical characters in a string

Trying to add formula to data validation that checks whether a string is either 6 numerical digits, or 6 numerical digits with hyphens or spaces. E.g.
123456
Or
12-34-56
Or
12 34 56
The string could also contain leading zeros.
The user should not be able to input a string that differs from the above formats, so
123-456
Or
1234567
....for example
Would prefer not to use VBA, but am struggling to make this into a data validation formula.
Any ideas would be appreciated
Try this:
=AND(SUBSTITUTE(SUBSTITUTE(A1," ",""),"-","")*1<=999999,SUBSTITUTE(SUBSTITUTE(A1," ",""),"-","")*1>=1,LEN(SUBSTITUTE(SUBSTITUTE(A1," ",""),"-",""))=6)
This formula removes hyphens and spaces, then checks if the number is 6 digits and that it falls between 1 and 999999. If there are any letters/symbols, the *1 part will cause an error.
Edit:
#JvdV id right. I misread your requirements. Here is my second attempt:
=AND(OR(ISNUMBER(MATCH("??-??-??",A1,0)),ISNUMBER(MATCH("?? ?? ??",A1,0)),AND(IFERROR(A1*1,0)<=999999,IFERROR(A1*1,0)>=1)),ISNUMBER(SUBSTITUTE(SUBSTITUTE(A1,"-","")," ","")*1))
Here is what it allows and doesn't allow:

Need to add 0 to match the length

I have unique identifiers for each row. For example 19Jan187938 or 19Jan206414 but there are some which are like 19Jan17333. I need to add a 0 before the number if it's 5 digits, so it becomes 19Jan017333.
I tried,
=TEXT(CONCATENATE(19,AB2,C2),"000000")
even with 11 0's, since the total length is 11. Nothing changes.
Try the following:
=CONCATENATE(LEFT(AB2,5),TEXT(RIGHT(AB2,LEN(AB2)-5),"000000"))
It will basically, take the first 5 characters and concatenate that with the remaining characters formatted as a six digit number with leading zeroes
If your identifier is on A1, you can try this:
=IF(LEN(A1)<11;CONCATENATE(LEFT(A1;5);RIGHT("000000"&MID(A1;6;5);6));A1)
See what happens.

=IF(ISNUMBER(SEARCH.... the difference between 1 and 11

I am trying to convert a single column of numbers in excel to multiple depending on the content.
e.g. Table 1 contains 1 column that contains 1 or more numbers between 1 and 11 separated with a comma. Table 2 should contain 11 columns with a 1 or a 0 depending on the numbers found in Table 1.
I am using the following formula at present:
=IF(ISNUMBER(SEARCH("1",A2)),1,0)
The next column contains the following:
=IF(ISNUMBER(SEARCH("2",A2)),1,0)
All the way to 11
=IF(ISNUMBER(SEARCH("11",A2)),1,0)
The problem with this however is that the code for finding references to 1 also find the references to 11. Is it possible to write a formula that can tell the difference so that if I have the following in Table 1:
2, 5, 11
It doesn't put a 1 in column 1 of Table 2?
Thanks.
Use, for list with just comma:
=IF(ISNUMBER(SEARCH(",1,", ","&A2&",")),1,0)
If list is separated with , (comma+space):
=IF(ISNUMBER(SEARCH(", 1,", ", "&A2&",")),1,0)
A version of LS_dev's answer that will cope with 0...n spaces before or after each comma is:
=IF(ISNUMBER(SEARCH(", 1 ,",", "&TRIM(SUBSTITUTE(A2,","," , "))&" ,")),1,0)
The SUBSTITUTE makes sure there's always at least one space before and after each comma and the TRIM replaces multiple spaces with one space, so the result of the TRIM function will have exactly one space before and after each comma.
How about using the SUBSTITUTE function to change all "11" to Roman numeral "XI" prior to doing your search:
=IF(ISNUMBER(SEARCH("1",SUBSTITUTE(A2, "11", "XI"))),1,0)
If you want to eliminate "11" case, but this is all based on hardcoded values, there should be a smarter solution.
=IF(ISNUMBER(SEARCH(AND("1",NOT("11")),A2)),1,0)

Resources