REPT function
Quick answer
REPT repeats a piece of text a given number of times.
- Syntax
=REPT(text, number_times)- Most common use
=REPT("|",B2/100)returns |||||||||||| (An in-cell bar: one mark per $100 of sales)
It's handy for quick in-cell bar charts, star ratings and padding codes to a fixed length, all without charts or extra columns.
- Available in
- Every current version
- Category
- Text functions
- Returns
- Text: the input repeated number_times times.
- Google Sheets
- Works the same in Google Sheets.
Syntax
=REPT(text, number_times)
| Argument | Required? | What it is |
|---|---|---|
text | Required | The text to repeat. |
number_times | Required | How many times to repeat it. Decimals are cut off, and 0 returns an empty string. |
Examples
Each result below is calculated from the sample sheet by our formula engine, the same one that grades the practice.
| Cell | Formula | Result | What it shows |
|---|---|---|---|
| D2 | =REPT("|",B2/100) | |||||||||||| | An in-cell bar: one mark per $100 of sales |
| D3 | =REPT("★",C3)&REPT("☆",5-C3) | ★★★★★ | A star rating out of five |
| D4 | =REPT("0",6-LEN(B4))&B4 | 002140 | Pads a number to six characters with leading zeros |
Try it live
This is the sample sheet. Change any number or text, or edit a formula, and the results update.
Show the sample data as a table
| Rep | Sales | Rating | Result |
| Ana | 1250 | 4 | |||||||||||| |
| Raj | 860 | 5 | ★★★★★ |
| Lee | 2140 | 2 | 002140 |
Practice REPT
Graded instantly, then re-checked on changed data.
Bars in cells
C2, draw a bar with one | character for each order in B2. Fill down to C6.Common mistakes
| What you see | Why, and how to fix it |
|---|---|
| #VALUE! on big numbers | The result can't be longer than 32,767 characters, the most a cell can hold. Scale the count down, for example B2/100. |
| #VALUE! on negative numbers | A negative number_times is an error. Guard it: =REPT("|",MAX(0,B2)). |
Tips
- Format the bar column in a monospaced font such as Consolas so equal values line up exactly.
Questions
How do I make an in-cell bar chart without a chart?
=REPT("|",B2/10) draws one bar character per 10 units. Conditional formatting data bars are the built-in alternative.
How do I repeat text in Excel?
=REPT("ab",3) returns "ababab". The second argument sets how many copies you get.
Answers that use REPT
In other languages
REPT is REPETIR in Spanish Excel and WIEDERHOLEN in German Excel. Each page has the syntax with semicolons, the examples and the exercise in that language. For other functions and languages, use the Function Translator.
Updated Checked by running: every formula on this page was run by our formula engine on .