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}")
Related
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)
I have cell phone numbers in Excel some with country code- 91 and some without country code. I need to remove the country code. We have 10 digit phone numbers so I need to remove the first two digits if the character length of the cell is greater than 10, i.e. if I have a number with country code like 917465785236 I need to remove the first two digits- 91 so that I only have 7465785236. I am trying the below piece but it doesn't check the IF condition and removes the first two digits from all the cells. Can someone tell me what's wrong I am doing here:
=IF((LEN(A1>10)),RIGHT(A1, LEN(A1)-2))
You probably need to put the parentheses differently for the Len function:
=IF((LEN(A1)>10),RIGHT(A1, LEN(A1)-2))
You're not using the parenthesis properly. Also since you strictly want to have 10 characters, you don't need to calculated the length in the RIGHT formula.. It needs to be like this:
=IF(LEN(A1)>10,RIGHT(A1, LEN(A1)-2),A1)
Now, that is the issue with your formula, but the solution to your question doesn't even need a IF statement, You can simply use:\
RIGHT(A1,10)
It will automatically get the 10 characters at the end and remove the rest.
I have a list of 12 digit alphanumeric codes and I need to match against a list of entries where codes might be misspelled.
For example, if the exact code is "K4I3T9OTG9GZ" the entry I have to check might be "K413T90TGS" (1 instead of capital I, 0 instead of capital O, S instead of Z).
I need to do a partial match to be able to find the right code.
Any ideas?
I already tried VLOOKUP with wildcards which worked for most entries with at least five consecutive right characters, but I still have a couple of hundred entries with no match.
Maybe this will help (array formula - Ctrl+Shift+Enter):
=SUMPRODUCT(--ISNUMBER(MATCH(MID($B$2,ROW($A$1:$A$12),1),MID($B$1,ROW($A$1:$A$12),1),0)))
The formula will check each character, one by one, and compare it against the "original"/"exact" code. In your example the result would be 7, as seven characters are matched exactly:
K 4 - 3 T 9 - T G -
{1;1;0;1;1;1;0;1;1;0;0;0}
Here's the full picture:
I've found some tools that can do what I want, but despite trying various options I can't work out how to put them in my existing formula!
I'm trying to generate an invoice reference number, which would look like 'ABC000012' - with the first row being ABC000001 and increasing in number as each row is added. I can currently generate 'ABC1' and so on, but can't work out how to add the preceding 0s.
I'm currently using CONCATENATE as follows:
=IF(ISBLANK(B2),,CONCATENATE("ABC",(ROW(1:1))))
What do I need to add to this, and where, in order to get the references I'm looking for?
I'm also happy to be advised that I should change the whole formula if there's something different that will work better
Thanks
Use TEXT() to set the preceding 0:
=IF(ISBLANK(B2),"",CONCATENATE("ABC",TEXT(ROW(1:1),"000000")))
=IF(ISBLANK(B2),"","ABC"&RIGHT("000000"&ROW(1:1),6))
This is based off Scott Craner's answer. The difference is that is will limit the number of digits in your invoice to 6 characters. if you want it to always be 8 characters long change the 6 to an 8 and increase the number of 0 between the " ". Alternatively you could also do:
=IF(ISBLANK(B2),"","ABC"&RIGHT(rept(0,6)&ROW(1:1),6))
In the above formula to change the number of digits n the invoice number, you would need to change both 6's
Caveat:
If there is a blank cell in the middle of your list, that number will be skipped for each blank cell. To avoid this, you will need a different counting method than row(1:1).
I want to partially mask names on excel after concatenating:
A1: David Goliath
B1 (output): Dav*******ath
Please help. I need the 1st three and and last 3 characters shown and the rest to be replaced by a special character. Since this formula will be applied on a long list, the length of names would vary.
Formula
=LEFT(A1,3)&REPT("*", LEN(A1)-6)&RIGHT(A1,3)
Picture
How it works
This formula relies on string manipulation to grab the first 3 characters, last 3 characters, and a string of * in the middle. This assumes that the entries are at least 6 characters long. If you want it to work for less than 6, you would need to decide how to hide the middle.
The only real trick is knowing that the number of * you need is 6 less than the length of the string since you are taking 3 characters from the front and back.