Function · Text
Excel REPT function
The Excel REPT function repeats text. Four asterisks are REPT("*", 4). A count of 0 returns an empty string, and a negative count is #VALUE!.
Syntax =REPT(text, number_times)
=REPT("*",4)Arguments
| Name | Required | What to pass |
|---|---|---|
| text | Required | The text to repeat. |
| number_times | Required | How many times. A fraction is cut down to the integer. 0 returns empty text. A negative number is #VALUE!. |
Examples
Four asterisks
=REPT("*",4)Result ****
| A | B | |
|---|---|---|
| 1 | Text | * |
| 2 | Times | 4 |
| 3 | Result | **** |
REPT repeats a piece of text. * four times is ****. A count of 0 is an empty string, which is useful when you want a marker only if a count is positive. A fraction is cut toward zero first, so 4.9 still means four copies.
The result is text, and it cannot exceed 32,767 characters. People use REPT to pad a code with zeros on the left, =REPT("0",5-LEN(A1))&A1, when the code must stay text. A number format can show leading zeros too, and it does not change the value into text. Use REPT when the padded result has to be text.