In excel I am using the left,mid and Right functions to pull the 'suffix' of a string.
Example:
1234-1234567-1234
The prefix is 4 digits long
The Base is 7 or 8 digits long
and the Suffix is either 3 or 4 digits long.
I have the right formula as: =RIGHT(A6,LEN(A6)-FIND("-",A6)-8) to handle the varying lengths of the suffix
I need the MID formula that pulls the base section that can handle the varying lengths of the base and suffix.
Given
The prefix is 4 digits long The Base is 7 or 8 digits long....
then you can use this formula
=MID(A1,6,8-ISERR(MID(A1,13,1)+0))
Please try:
=MID(A1,1+FIND("-",A1),FIND("-",MID(A1,1+FIND("-",A1),9))-1)
(just for the part between the hyphens).
But Text to Columns with - as delimiter might be more convenient.
You could try:
=MID(A1,6,FIND("-",A1,6)-FIND("-",A1,1)-1)
Related
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)
Question relates to Excel (Office365):
I am seeking a solution that will extract a number with a length of 4 digits from a string.
A couple of examples of the type of strings I am referring to are:
"16016KT 9999 SCT030"
"PROB30 0500 FG BKN001"
"MOD TURB BLW 5000FT TILL302300"
"INTER 6000 SHRA SCT015"
In each of the above strings there are a combination of letters and numbers of varying lengths and no set pattern.
The sequence of characters that I am interested in are the 4 digit numbers (in BOLD). Not, the 5000 in 5000ft.
The sequence of 4 digits is unique to all the strings I will be evaluating.
Thanks!
You may use:
=IFERROR(TEXT(FILTERXML("<t><s>"&SUBSTITUTE(A1," ","</s><s>")&"</s></t>","//s[.*0=0][string-length()=4]"),"0000"),"Non found")
On more recent versions of Excel, you may try:
=RegexpFind(A1, "\b[0-9]{4}\b", 0)
See here for how to activate regex support in Excel.
another solution:
=IFERROR(TEXT(UNIQUE(SEQUENCE(9999)/(FIND(" " & TEXT(SEQUENCE(9999),"0000") &" ",A2)>0),,1),"0000"),"")
Another option
In B1, formula copied down :
=IFERROR(TEXT(0+MID(A1,SEARCH(" ???? ",A1)+1,4),"0000"),"not found")
I am looking for generating alpha numeric series of 3 digits as below:
0A0 to 9Z9
i.e. 0A0, 0A1,... 0A9, 0B0.... 9Z9
Is there any way in excel to generate the above sequence?
I tried many formulas but not able to do with alpha numeric.
You can try, in some cell:
=INT((ROWS($1:1)-1)/260)&CHAR(MOD(INT((ROWS($1:1)-1)/10),26)+65)&MOD(ROWS($1:1)-1,10)
Then fill down to a total of 2600 rows
EDIT: If you want to repeat the sequence after 2600 rows, then try:
=MOD(INT((ROWS($1:1)-1)/260),10)&CHAR(MOD(INT((ROWS($1:1)-1)/10),26)+65)&MOD(ROWS($1:1)-1,10)
It's easy!
You're trying to =CONCATENATE() a series made of random integers and random strings.
a RANDOM INTEGER from 0 to 9 --------------- =RANDBETWEEN(0;9)
a RANDOM CHARACTER from A to Z --------- =CHAR(RANDBETWEEN(65;90)) ¹
a RANDOM INTEGER from 0 to 9 --------------- =RANDBETWEEN(0;9)
¹ See more at ASCII Character Map
Final Formula:
=CONCATENATE(RANDBETWEEN(0;9);CHAR(RANDBETWEEN(65;90));RANDBETWEEN(0;9))
So, we used:
=CONCATENATE()
=RANDBETWEEN()
=CHAR()
An ASCII Character Map
Or if you're not interested in random numbers and chars, should be easy to create a column with the necessary numbers to generate a specific sequence.
But.... if you want all combinations possible using these variables, or in numbers, all the 2500 combinations possible, you should create a macro. I mean... it's doable using formulas, but is way easier to accomplish this using vba.
I have an Excel spreadsheet with over 2000 entries:
Field B1: CustomerID as 000012345
Field B2: CustomerID as 0000432
Field C1: CustomerCountry as DE
Field C2: CustomerCountry as IT
I need to build codes 13 digits long including "CustomerCountry" + "CustomerID" without leading 0 + random number (can be 6 digits, more or less, depends in length of CustomerID).
The results should be like this: D1 Code as DE12345967895 or D2 Code as IT43274837401
How to do it with Excel functions?
UPDATED:
I tried this one. My big problem is to say that random number should be long enough to get 13 characters in all. Sometimes CustomerID is just 3 or 4 digits long, and concatenation of three variables can be just 10 or 9 characters. But codes have to be always 13 characters long.
Use & to concatenate strings.
Use VALUE(CustomerID) to trim the leading zeroes from the ID
Use RAND() to add a random number between 0 and 1 or RANDBETWEEN(x,y) to create one between x and y.
Combine the above and there you are!
If you always want 13 digits you can use LEFT(INT(RAND()*10^13);(13-LEN(CustomerCountry)-LEN(VALUE(CustomerID)))) for the random number to ALWAYS be the right length.
total formula
= CustomerCountry
& VALUE(CustomerID)
& LEFT(INT(RAND()*10^13);(13-LEN(CustomerCountry)-LEN(VALUE(CustomerID))))
=C1 & TEXT(B1,"0") & RIGHT(TEXT(RANDBETWEEN(0,99999999999),"00000000000"),11 - LEN(TEXT(B1,"0")))
that should do it
I don’t understand what is where and OP has accepted answer so have not bothered testing:
=LEFT(RIGHT(C1,2)&VALUE(MID(B1,15,13))&RANDBETWEEN(10^9,10^10),13)
(but I might revert to this if no one else picks the flaws in it first!)
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.