Repeats a piece of text as many times as you ask.
REPT repeats text. =REPT("-", 20) gives twenty hyphens. On its own that sounds like a novelty, and its two real uses are both about turning a number into something you can see at a glance.
The first is the in-cell bar chart. Repeat a block character as many times as the value, and a column of numbers becomes a column of bars that scales as the data changes — no chart object, no conditional formatting, just a formula. Divide the value first to keep the bars a sensible width.
The second is star ratings, which is the same trick with two characters: repeat a filled star for the score and an empty one for the remainder. Both patterns work in any Excel version and survive being copied into an email.
=REPT(text, number_times)textnumber_timesHeaders in row 1, data in A2:C5. Column B arrived as text, not numbers.
| A | B | C | |
|---|---|---|---|
| 1 | Reference | Amount (text) | Score |
| 2 | INV-1041 | 1240.50 | 4 |
| 3 | INV-1042 | 385.00 | 2 |
| 4 | INV-1043 | 2100.75 | 5 |
| 5 | INV-1044 | 940.20 | 3 |
=REPT("█", C2)Result: ████
The in-cell bar chart. Four blocks for a score of 4, growing and shrinking with the value.
=REPT("★", C4) & REPT("☆", 5 - C4)Result: ★★★★★
A five-star rating: filled stars for the score, empty ones for the rest, joined with &.
=REPT("-", 20)Result: --------------------
A separator line, sized once and reused.
=A2 & REPT(" ", 12 - LEN(A2)) & B2Result: INV-1041 1240.50
Padding to a fixed width, which lines up columns in a monospaced export or a plain-text email.
Reading about a formula is not the same as writing one. Open this function's exercise and type it into a real grid — you get instant feedback on exactly which cell is wrong and why.
Why it happens: The result would exceed 32,767 characters, which is the maximum a cell can hold.
How to fix it: Scale the repeat count down. A bar chart divided by a sensible factor never comes close to this.
Why it happens: If LEN(text) is longer than the target width, the subtraction goes negative and REPT rejects it.
How to fix it: Wrap it in MAX: REPT(" ", MAX(0, 12 - LEN(A2))).
Why it happens: The value is being used directly as the repeat count.
How to fix it: Divide first: =REPT("█", ROUND(B2/100, 0)) keeps the width readable.
=REPT("█", ROUND(B2/scale, 0)), where scale keeps the longest bar to a sensible number of characters. Set the font to something monospaced and the bars line up perfectly down the column.
=REPT("★", B2) & REPT("☆", 5 - B2) gives a five-star display where B2 is the score. The two REPTs handle the filled and empty portions and & joins them.
Either the result would exceed the 32,767-character cell limit, or the repeat count is negative — usually from a subtraction that went below zero when padding text. Wrap the count in MAX(0, …) to guard it.
Longer reads where this function does real work in a real sheet.