Applies ToExcel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web Excel 2024 Excel 2024 for Mac Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2016

This article describes the formula syntax and usage of the REPT  function in Microsoft Excel.

Description

Repeats text a given number of times. Use REPT to fill a cell with a number of instances of a text string.

Syntax

REPT(text, number_times)

The REPT function syntax has the following arguments:

  • Text    Required. The text you want to repeat.

  • Number_times    Required. A positive number specifying the number of times to repeat text.

Remarks

  • If number_times is 0 (zero), REPT returns "" (empty text).

  • If number_times is not an integer, it is truncated.

  • The result of the REPT function cannot be longer than 32,767 characters, or REPT returns #VALUE!.

Example

Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For formulas to show results, select them, press F2, and then press Enter. If you need to, you can adjust the column widths to see all the data.

Formula

Description

Result

=REPT("*-", 3)

Displays an asterisk and a dash (*-) 3 times.

*-*-*-

=REPT("-",10)

Displays a dash (-) 10 times.

----------

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.