Excel Function: REPT
Purpose
The REPT function generates and returns a text value consisting of 1 or more copies of a value passed to its text argument. The number passed to REPT’s number_times argument specifies the number of copies it will make. If the value passed to number_times is equal to zero (0), then the REPT function returns the empty text value (“”) and if it is not an integer then it is rounded down. For example, 2.9 will be treated as being 2.
Invocations of the REPT function take the form:
REPT(text,number_times)
Arguments
Argument Argument type Description text Mandatory A text value to be replicated by the REPT function. number_times Mandatory The number of times the value passed to the text argument will appear in the result of REPT.
Error Conditions
Error value Condition type Condition #VALUE! Bad argument The value passed to the number_times argument was ≤ -1. #VALUE! Runtime The text value generated by REPT exceeded 32,767 characters in length.
Examples
Example Formula Result Description 1 =REPT("ABC ",5)
ABC ABC ABC ABC ABC
Generate a text value containing “ABC ” repeated 5 times. 2 =REPT("ABC ",2.9)
ABC ABC
Generate a text value containing “ABC ” repeated 2.9 times.The REPT function rounds 2.9 down to 2. A text value containing 2 copies of “ABC ” is returned. 3 =REPT("ABC",0)
Generate a text value containing “ABC ” repeated 0 times.Because number_times equals zero (0), the empty text value is returned. 4 =REPT(DATE (2023,9,4),2)
4517345173
Generate a text value containing the date 4 September 2023 ” repeated 2 times.
Examples: Errors
Example Formula Result Description 1 =REPT("ABC",-1)
#VALUE!
Generate a text value containing “ABC ” repeated -1 times.Because it isn’t possible to create -1 copies of a text value, #VALUE is returned. 2 =REPT("ABC ",8192)
#VALUE!
Generate a text value containing “ABC ” repeated 8192 times.Copying “ABC ” 8192 times would yield a text value 32768 characters in length. The REPT function is limited to generating text values ≤ 32,767 characters in length. Because this limit would be exceeded, #VALUE! is returned.