Technology Sharing

Excel - REPLACE function to encode sensitive information

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

first step:

Take the material Excel document as an example.

Enter the function "=REPLACE(B2,4,5,"*****")" in cell F2. After entering, press the Enter key to start calculating, and use the fill handle to fill other areas.

This function means: the 5 numbers starting from the 4th digit are replaced by 5 "*".

Step 2:

Enter the function "=REPLACE(C2,7,10,"**********")" in cell G2. After entering, press the Enter key to start calculating, and drag down to fill the formula.

This function means: the 10 numbers starting from the 7th digit are replaced by 10 "*".

Please note:

①The double quotes in the function are the double quotes in English.

②The “*” in the formula can be replaced by other characters and adjusted as needed.

Function analysis:

The REPLACE function replaces Old_text (old string) in a string with New_text (new string).

Syntax: REPLACE(Old_Text,Start_Num,Num_Chars,New_Text).

Translation: REPLACE (original string, starting position, number of characters, new string).

Old_Text indicates the character text that needs to be replaced.
Start_Num indicates the starting position of the characters in Old_Text to be replaced by New_Text.
Num_Chars indicates the number of characters in Old_Text that you want REPLACE to replace with New_Text.

New_Text represents the text to be used to replace the characters in Old_Text.

If you want to use the REPLACE function to make the key information in the original string disappear, instead of replacing it with special characters, you only need to delete the "*" in the new string, for example: "=REPLACE(B2,4,5,"")". This will make the key information in the original string disappear.