I have a list of numbers which are separated by hyphens. The format and length is always the same. Example:
65-09-27-542400-6147
I want to retrieve the 6 digits from after the third hyphen. Using the data in the above example, the result is:
542400
My formula can only retrieve the numbers from after the first hyphen. Using above example, this will be 09:
=IFERROR(MID(A1,SEARCH("-*-",A1)+1,SEARCH("-",SUBSTITUTE(A1,"-","^",1))-SEARCH("-*-",A1)-1),"")
How can I adjust my current formula to retrieve the 6 digits after the third hyphen instead?
You can also try:
=regexextract(A1,"\d{6}")
I think the easiest and most efficient is to use the MID function if they are all the exact format:
=mid(A1,10,6)
Use SPLIT() function.
=INDEX(TRANSPOSE(SPLIT(A1,"-")),4)
Related
I have data as follows in excel/google sheets.
Numbers that have a length of 19 characters need to be manipulated in this way
For all strings with a length of 19 last 6 digits need to be trimmed, ( i can easily do it )
and remove the leading prefix which is either 200 or 20000
for example
2005507187528000001 to 5507187528 |
2000017303364000001 to 17303364
Have no idea what to do to remove the prefix, I tried trimming the last 14 digits to get 20000 or 20055 and using this to determine if I need to take out the first 3 or first 6, but no success.
Please help !!!
thanks
If I understood your question correctly you want to remove the first N characters whether it is 200 or 20000.
Try:
=IF(LEFT(A2,5)="20000",RIGHT(A2,LEN(A2)-5),RIGHT(A2,LEN(A2)-3))
Drag down to column.
Result:
Explanation:
Using the LEFT() function you can extract the first 5 characters. You can then use an IF() to check if it is equal to 20000. Then using the Combination of RIGHT() and LEN() to remove the first N characters. If it is equal to 20000 remove the first 5 characters, if not then remove the first 3 characters.
Using an ArrayFormula:
=ARRAYFORMULA(IF(A2:A="","",IF(LEFT(A2:A,5)="20000",RIGHT(A2:A,LEN(A2:A)-5),RIGHT(A2:A,LEN(A2:A)-3))))
Here's a way using arrayformula so you don't have to drag down/copy to cells below. This of course still needs to be adjusted to your range.
Note: I have not included the formula to remove the last 6 characters since according to you you already have this, so you can just add this formula to yours.
For all strings with a length of 19 last 6 digits need to be trimmed,
( i can easily do it )
References:
Remove the First N Characters in a Cell in Google Sheets - Multiple ways to remove the first N characters, refer to this link.
LEFT()
IF()
try:
=INDEX(IFERROR(REGEXEXTRACT(A2:A&""; ".{6}$")))
update:
=REGEXEXTRACT(F905&""; "^20+(\d.*)\d{6}")
If I have entered a certain 4 digit number for example ,1234 how do I choose like the first 2 numbers or the last two numbers from the cell by that i mean suppose i want it to return 34 for the last two digits and I want it to return 12 for the first two digits. So anytime I change my 4 digit number it works the same way.
You may use the LEFT and RIGHT functions, e.g.
=LEFT("1234", 2)
=RIGHT("1234", 2)
If your 4-digit number is, in fact, a string you can parse the string as suggested by #Tim Biegeleisen. In my Excel 365, when I enter 1234 in a cell formatted as General I can use the same method.
=LEFT(A1, 2)
and
=Right(A1, 2)
However, this conversion of a number to text mustn't be presumed to work under all circumstances. Therefore you may prefer to convert the number to text explicitly in the formula.
=LEFT(TEXT(A1,"0000"), 2)
and
=Right(TEXT(A1,"0000"), 2)
This method has the added advantage of being able to handle numbers of less than 4 digits.
On the other hand, you can also extract first and last digits from a true number, without converting it to text.
=INT(A1/100)
and
=MOD(A1,100)
The main difference is that the results are also numbers (all partial strings are text). Therefore this would be the preferred method if you don't want to worry about strings, text, numbers, numerics and cell formats.
I need to display with no decimal, but retaining the numbers that
appear after the last decimal. For example, given `03.1037.190
I tried roundup and trunct but not sure how it works.
Try this on a string where . could be on a dynamic spot
=SUBSTITUTE(A1,".","",LEN(A1)-LEN(SUBSTITUTE(A1,".","")))
Or when your string always follows the same pattern ##.####.####.## you could try:
=REPLACE(A1,13,1,"")
The question is quite unclear as you have a value with the same thousand and decimal delimiter and also 4 numbers between the delimiters. It would help a lot if you specified the actual number without thousand delimiters.
Assuming there are no decimals (31.037.190.301): remove "." using:
=SUBSTITUTE(A1,".","")
and Excel will recognize it as a number
I have cells that contain both numbers and special characters such as this:
[1:250:10]
The 'coordinates' shown above can be in the following format.
[(1-9):(1-499):(1-15)] in terms of what numbers can be within each part.
How do I extract these three numbers into three separate cells?
Assuming your data is in Cell A1 the to extract first number use following formula
=MID(A1,2,(FIND(":",A1,1)-2))
for second number use
=SUBSTITUTE(MID(SUBSTITUTE(":" & A1&REPT(" ",6),":",REPT(":",255)),2*255,255),":","")
finally for third number enter
=SUBSTITUTE(TRIM(RIGHT(SUBSTITUTE(A1,":",REPT(" ",LEN(A1))),LEN(A1))),"]","")
Just tossing out some other options.
First number since it only has a length of 1 digit and is on the left side, use the following:
=RIGHT(LEFT(A1,2))
second number will be found by locating the : in the string
=MID(A1,FIND(":",A1)+1,FIND(":",A1,FIND(":",A1)+1)-(FIND(":",A1)+1))
third number will be dealt with in the same way as the second but we will use the second : and the ] as the identifiers as to where to grab from and how much to pull.
=MID(A1,FIND(":",A1,FIND(":",A1)+1)+1,FIND("]",A1)-(FIND(":",A1,FIND(":",A1)+1)+1))
now all those number will actually come through as text. If you want to have them as numbers in the cells, send them through a math operation that will not change their value. Do something like +0, -0, or *1 at the end. Alternatively you could add -- at the start of each formula (yes that is double - incase you were wondering if it was a typo)
I have a column (F) full of 11 digit numbers, what I need is to split them like the following: 12,345,6789,00
I have the following formula which adds a comma after the first two digits however I don't know how to get it to add them in after the next 3 then 4.
=LEFT(F2,2)&","&MID(F2,3,LEN(F2))
The above formula outputs like this: 12,345678900
Any suggestions?
Have you considered using the TEXT function? This is simple and would do the trick:
=TEXT(F2,"00"",""000"",""0000"",""00")
Use MID all the way:
=MID(F2,1,2)&","&MID(F2,3,3)&","&MID(F2,6,4)&","&MID(F2,10,2)
=left(F2,2)&","&mid(F2,3,3)&","&mid(F2,6,4)&","&right(F2,2)
Will give you what you want.
=LEFT(F2,2) &","&MID(F2,3,3)&","&MID(F2,6,4)&","&RIGHT(F2,2)
Try using the Text to Columns function in the Data Tab of Excel. It will allow you to split the numbers based on number of digits. For this to work though, it needs to be the case that the number ALWAYS has 11 digits... otherwise some numbers will get cut in the wrong spot.
You can then Concotenate them back together with Commas inbetween.