REPT

Build a string by repeating another one.

Syntax

REPT(text, number_times)
Argument Required Description
text Required The text to repeat.
number_times Required How many times to repeat it.

Examples

Every example below was executed against VisiGrid engine 0.35.0 — not transcribed from another vendor's documentation. Reproduce any of them with vgrid calc.

Formula Result Notes
=REPT("ab",3) ababab
=REPT("0",3) 000
=RIGHT(REPT("0",3)&"7",3) 007 The standard zero-padding pattern.

Zero-padding, because TEXT cannot yet

Fixed-width identifiers — 007, 0042 — are normally written TEXT(7,"000") in Excel. VisiGrid’s TEXT does not implement leading-zero format codes yet, so the portable construction is:

=RIGHT(REPT("0", 3) & A1, 3)

Pad generously on the left, then take the rightmost n. It works in every spreadsheet, and it will keep working when TEXT catches up.

Worth knowing that the result is text, not a number with leading zeros — there is no such thing. A cell showing 007 is either text or a number with a display format, and this produces the former.

In-cell bar charts

REPT with a block character makes a crude bar chart that needs no chart at all: =REPT("█", A1/100). Useful in a table where a real chart would be overkill, and it survives being exported to CSV.

Excel compatibility

Matches Excel.

Related functions

Last updated