REPT can be used to pad values to a certain length or to build a simple in-cell histogram. To pad numeric values with zeros, a custom number format may be a better option.
Examples
To repeat “x” five times, you can use the following formula: 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 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.
Notes
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 ("").
Dave Bruns
Hi - I’m Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.