Documentation/Calc Functions/REPT

From The Document Foundation Wiki
Jump to navigation Jump to search
Other languages:
English • ‎Nederlands



Function name:

REPT

Category:

Text

Summary:

Creates a new text string by concatenating multiple copies of a supplied string.

Syntax:

REPT(Text; Number)

Returns:

Returns a text string that comprises a specified number of copies of a supplied string.

Arguments:

Text is a text string (in quotation marks), a number, or a reference to a cell containing one of those types, that specifies the string to be repeated.

Number is a non-negative integer, or a reference to a cell containing a non-negative integer, that is the number of repetitions required.

  • If Number is non-numeric, then REPT reports a #VALUE! error.
  • If Number is a non-integer value, then REPT truncates it to an integer value.
  • If Number is less than 0, then REPT reports an invalid argument error (Err:502).
  • If Text is equal to the empty string or Number is equal to 0, then REPT returns the empty string.
  • The length of the string to be returned is limited to be less than 256 * (1024)2 characters. If the arguments passed would cause this limit to be exceeded, REPT reports a string overflow error (Err:513).

Additional details:

None.

Examples:

Formula Description Returns
=REPT("-x-"; 3) Here the function repeats the supplied string three times, returning "-x--x--x-". "-x--x--x-"
=REPT(D1; D2) where cell D1 contains the string "-x-" and cell D2 contains the value 3. Here the function again repeats the supplied string three times, returning "-x--x--x-". "-x--x--x-"
=REPT(123; 2) In this example the text string is passed as a numeric argument, without quotation marks. Here the function repeats the supplied number twice, returning "123123". "123123"
=REPT("ha"; 4.75) The supplied value for the Number argument is truncated to 4. Here the function repeats the supplied string four times, returning "hahahaha". "hahahaha"
=REPT(""; 17) Since the Text argument is the empty string, providing that the Number argument is a non-negative number, its exact value is unimportant. Here the function returns the empty string. ""
=REPT("Any string"; 0) Here the function returns the empty string, since the Number argument is set to 0. ""

Related LibreOffice functions:

None.

ODF standard:

Section 6.20.18, part 2

Equivalent Excel functions:

REPT