# REPT function in Excel

> REPT repeats a piece of text a given number of times.

Source: https://spreadsheetpractice.com/functions/rept · Updated October 28, 2026 · Formulas and results on this page were run by the Spreadsheet Practice formula engine on November 20, 2026

## Quick answer

- **What it does:** 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)
- **Available in:** Every current version
- **Category:** [Text functions](https://spreadsheetpractice.com/functions/category/text)
- **Returns:** Text: the input repeated number_times times.
- **Google Sheets:** Works the same in Google Sheets.

## What it does

REPT repeats a piece of text a given number of times. It's handy for quick in-cell bar charts, star ratings and padding codes to a fixed length, all without charts or extra columns.

## 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 was calculated by running the formula on the sample sheet.

| 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 |

### The sample sheet

Every formula above runs on this data:

|  | A | B | C | D |
|---|---|---|---|---|
| 1 | Rep | Sales | Rating | Result |
| 2 | Ana | 1250 | 4 | \|\|\|\|\|\|\|\|\|\|\|\| |
| 3 | Raj | 860 | 5 | ★★★★★ |
| 4 | Lee | 2140 | 2 | 002140 |

## 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.

## Related functions

- [LEN](https://spreadsheetpractice.com/functions/len): LEN counts the characters in a text string, including spaces and punctuation.
- [TEXT](https://spreadsheetpractice.com/functions/text): TEXT turns a number or date into text in the format you choose, such as "$1,250.00" or "March 2026".
- [CONCAT](https://spreadsheetpractice.com/functions/concat): CONCAT joins text from several cells or whole ranges into one string.

## 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.

## Practice

A graded REPT exercise ("Bars in cells") is on [the REPT page](https://spreadsheetpractice.com/functions/rept). It is checked instantly, then re-checked on changed data.

---

Spreadsheet Practice (https://spreadsheetpractice.com) teaches spreadsheet formulas by practice: every exercise is graded in a live grid and re-checked on changed data.
