Excel REPT Function
The Excel REPT function repeats characters a given number of times. For example, =REPT("x",5) returns "xxxxx".
- text - The text to repeat.
- number_times - The number of times to repeat text.
The REPT function repeats characters a specified number of times. Although REPT can repeat numbers as well as text, the result from REPT is always a text value. REPT takes two arguments, text and number_times. Text is the character(s) to repeat, and number_times is the number of times text should be repeated.
To repeat "x" five times, you can use the following formula:
=REPT("x",5) // returns "xxxxx"
Inputs to REPT can be variable. In the example shown above, REPT is configured to repeat the values in column B using the count in column C. The formula in D5 is:
=REPT(B5,C5) // returns "-----"
REPT can be combined with other functions to calculate a variable count. For example, to pad a text string with a specific character so that all strings are the same length, you can use REPT together with the LEN function like this:
In this formula, "count" is the desired final length in characters. Detailed explanation here.
The REPT function appears in more advanced formulas that solve some tricky problems. See below for more examples.
- REPT can repeat numbers but the result is text.
- Number_times should be zero or a positive integer, otherwise, REPT will return #VALUE!
- If number_times is zero, REPT returns an empty string ("").