Mask a text identifier except its final four

Show only the last four characters, like 012345678 → XXXXX5678.

What you'll make

In Excel: 012345678 becomes XXXXX5678.

The formula

The formula, with a numbered bracket under each part.
NumberPartWhat it doesResult so far
1REPT("X",MAX(0,LEN(A8)-4))Writes one X for each character before the last four."XXXXX"
2RIGHT(A8,4)Adds the last four characters as they are."XXXXX5678"

Read it left to right. MAX stops the count going below zero, so a short ID shows in full. The original cell doesn't change. The IDs here are made-up.

=REPT("X",MAX(0,LEN(A8)-4))&RIGHT(A8,4)

How to use it

Yellow bar at the top? Click Enable Editing.

  1. See it work. The Example tab shows 20 made-up examples with the formula already in.
  2. Use your own IDs. Paste IDs, stored as text, into the green column of the Template tab. The masked IDs fill in by themselves.
  3. Move them into your letter. Copy the results. Then use Paste Special and choose Values.

Before you send

An ID of four characters or fewer stays fully visible. Check short IDs before you share the list.

Microsoft's help: REPT function