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.
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}")
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.
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 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:
On a daily basis I need to load data to one of our systems. However Excel deletes the previous zeros in front of the contractor IDs. So i have to add THREE zeros manually. I normally use the CONCATENATE function however now the IDs are coming differently so some IDs now only need to have TWO zeros added.
example:
ID
911111
I use concatenate to make it look like:
000911111
I came up with the IF formula that detects if the ID starts with a number NINE, to concatenate TWO zeros and if not, then to add THREE zeros.
example:
=IF(LEFT(A32,1)="9",CONCATENATE("00",A32),CONCATENATE("000",A32))
Now I want to create this formula as a custom defined so I do not have to write down the formula ever time I work on the data every day.
Any suggestions I will really appreciate.
In addition to the formatting responses provided in the comments, you could use the RIGHT function to cut off the leading zeroes to the appropriate amount.
For example, assuming A1 holds a string of numbers, between 0 & 9 digits long. We can create text representing a 9 digit string, with as many leading zeroes as necessary, as follows:
=RIGHT(REPT("0",9) & A1,9)
REPT("0",9) tells Excel to repeat the character "0" 9 times. It then tacks on whatever text is in A1. Then it takes only the rightmost 9 characters of the concatenation.
I generally would recommend the Formatting options noted in those comments, unless you need the text to be 9 characters for other formula purposes.