How to Use REPLACE Formula in Excel (Video in Khmer) + Tips

Learn how to use REPLACE function in Excel step-by-step to swap or insert text based on position with simple examples.

Advertisement
Formula
=REPLACE(old_text, start_num, num_chars, new_text)

Hello everyone! Today i will show you how to use REPLACE formula in Microsoft Excel step by step. replace formula in excel example

If you have text, phone numbers, product codes, or dates and you want to swap specific characters at fixed position with new text (example: hide middle phone digits 012-345-678 into 012-***-678), the REPLACE formula help you very fast and easy!

📚 Related Tutorial: Want to clean extra spaces first? Check out How to Use Text Cleaning Formulas in Excel!

🛠️ Formula Syntax & How It Works

=REPLACE(old_text, start_num, num_chars, new_text)
  • old_text: The text cell you want to replace characters inside (example: A2).
  • start_num: Character position number where replacement start (example: 5).
  • num_chars: How many characters you want to delete/replace (example: 3).
  • new_text: The new text string you want to put in that position (example: "***" or "-").

📊 Simple Examples

Example 1: Hide Middle Digits of Phone Number (Data Privacy)

If cell A2 contain phone number "012-345-678":

=REPLACE(A2, 5, 3, "***")
  • Result: 012-***-678 (start at 5th character, replace 3 numbers with ***)

Example 2: Update Year inside Code or Date

If cell A2 contain code "2025-ITEM-001":

=REPLACE(A2, 1, 4, "2026")
  • Result: 2026-ITEM-001 (replace first 4 characters with "2026")

Example 3: Insert Dash - Without Deleting Characters

If cell A2 contain "ID1001" and you want "ID-1001":

=REPLACE(A2, 3, 0, "-")
  • Result: ID-1001 (set num_chars=0 to insert text without deleting!)
Advertisement

💡 Pro Tips for REPLACE Formula

  1. REPLACE vs SUBSTITUTE Difference:
    • REPLACE() swaps characters based on position index (example: start at character 5, replace 3 characters).
    • SUBSTITUTE() swaps characters based on matching text string (example: find all "2025" and change to "2026" regardless of position).
  2. Insert Text Without Deleting: Set num_chars = 0 to insert hyphen - or slash / into code strings without removing any existing letters!
  3. Mask Confidential Phone / ID Data: Use REPLACE to hide private customer phone numbers or ID cards before sharing reports.
  4. Combine with SEARCH: Use SEARCH() inside start_num to dynamically find position where replacement should start!

📚 Related Tutorials

Found this tutorial helpful? Share it with colleagues:
📚

Related Tutorials

Opens in new tab ↗
Advertisement