REPT function
Repeats a text a given number of times. Used for in-cell bar charts, star ratings and padding values with zeros.
Available in All versions of Excel, including Microsoft 365, Excel for Mac and Excel for the web
In every Excel versionWorks in Google Sheets
Syntax
REPT(text, number_times)| Argument | What it means | |
|---|---|---|
text | Required | The text to repeat, e.g. "*" or "0". |
number_times | Required | How many times to repeat it. Decimals are truncated; 0 returns an empty string. |
Returns: The repeated text.
How REPT works
REPT simply writes the same text several times in a row: =REPT("-",10) gives ten dashes. That sounds trivial, but it is the basis of several neat tricks: quick bar charts inside cells, star ratings, progress bars, and padding numbers with leading zeros to a fixed width.
The number of repetitions is truncated to a whole number, so REPT("|",7.9) gives 7 bars. Zero gives an empty string and a negative number gives #VALUE!. The result cannot be longer than 32,767 characters.
For in-cell charts, choose a character that is the same width every time (| or the block character UNICHAR(9608)) and a font such as Consolas, so bars of equal value line up.
Examples
1In-cell bar chart of sales
| A | B | C | |
|---|---|---|---|
| 1 | Rep | Sales (k) | |
| 2 | Ana | 73 | ||||||| |
| 3 | Ben | 45 |
Result: |||||||
73/10 = 7.3, truncated to 7 bars. Fill down to get a quick visual comparison next to the numbers.
2Pad an ID with leading zeros
| A | B | |
|---|---|---|
| 1 | Employee no. | |
| 2 | 742 | 000742 |
Result: 000742
The number has 3 digits, so 3 zeros are added in front to make a 6-character ID. TEXT(A2,"000000") gives the same result.
3Star rating
| A | B | C | |
|---|---|---|---|
| 1 | Product | Rating | |
| 2 | Desk Lamp | 3 | ★★★☆☆ |
Result: ★★★☆☆
Three filled stars followed by two empty ones make a 5-star scale.
Common errors and how to fix them
| Error | Why it happens | Fix |
|---|---|---|
#VALUE! | number_times is negative, or the result would exceed 32,767 characters. | Wrap the count in MAX(0, ...) and keep the result short. |
Tips
- Scale large numbers down before using them in REPT, otherwise a value of 25,000 tries to draw 25,000 characters.
- Use UNICHAR to get special symbols for bars and ratings, e.g.
UNICHAR(9608)for a solid block. - Conditional formatting data bars are a more polished alternative for dashboards, but REPT works in plain-text exports.
Google Sheets
REPT also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.
REPT in other languages
In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.
| Language | Function name |
|---|---|
| Czech | OPAKOVAT |
| Danish | GENTAG |
| Dutch | HERHALING |
| Finnish | TOISTA |
| German | WIEDERHOLEN |
| Hungarian | SOKSZOR |
| Italian | RIPETI |
| Norwegian (Bokmål) | GJENTA |
| Polish | POWT |
| Portuguese (Portugal) | REPETIR |
| Russian | ПОВТОР |
| Spanish | REPETIR |
| Swedish | REP |
| Turkish | YİNELE |