A remittance advice should show which account the money went to without printing the whole account number. REPLACE swaps a stretch of characters in the middle of a text for something else, and with LEN and REPT working out how long that stretch is, one formula masks an account number of any length.
You send out the Friday payment run's remittance advices, and finance has asked that they stop printing suppliers' full bank details. A2:B7 lists each supplier and the IBAN they were paid into. The IBANs come from six countries, so they are not all the same length. In C2, show the IBAN with its first 4 and last 4 characters kept and every character in between replaced by an asterisk, so GB33BUKB20201555555555 becomes GB33**************5555. The masked version must be exactly as long as the original. Copy the formula down to C7.
Solve it on your own to keep the bonus. Each hint gets one step closer to the formula.
This is the grid you start with. Cell references in the task — B6, C2 — point at the row numbers and column letters below.
| A | B | C | |
|---|---|---|---|
| 1 | Supplier | IBAN | Masked IBAN |
| 2 | Hartley Packaging Ltd | GB33BUKB20201555555555 | |
| 3 | Kessler Logistik GmbH | DE75512108001245126199 | |
| 4 | Atelier Moreau SARL | FR7630006000011234567890189 | |
| 5 | Van Dijk Pallets BV | NL91ABNA0417164300 | |
| 6 | Brennan Print Ltd | IE64IRCE92050112345678 | |
| 7 | Peeters Labels NV | BE71096123456769 |
REPLACE works by position, not by content: it starts at a character number, removes a stated number of characters and puts new text in their place, whatever those characters were. That suits an IBAN, where what to hide is defined by where it sits rather than what it says. The first 4 characters (the country code and check digits) stay, so the hidden stretch starts at position 5. Its length is everything except the 8 characters you keep, which is LEN(B2)-8: 14 for the 22-character British, German and Irish IBANs, 19 for the French one, 10 for the Dutch one and 8 for the Belgian one. REPT("*",LEN(B2)-8) builds a row of asterisks exactly that long, so the masked IBAN is the same length as the real one and the last 4 characters land where the reader expects them. That is why the count is worked out rather than typed: fourteen asterisks typed into the formula look right on the first row, but on the French row they leave five real digits showing and on the Belgian row they hide characters that belong to the last four. Because both the removed length and the asterisk count come from the same LEN, they always agree. =LEFT(B2,4)&REPT("*",LEN(B2)-8)&RIGHT(B2,4) builds the same result from the outside in and is just as correct; REPLACE says more plainly that you are covering up the middle of something that otherwise stays as it is.