Excel tutorial

How to repeat text in Excel.

Excel has a built-in function called REPT that duplicates any text a specified number of times. Here's how to use it, including a few useful combinations.

The REPT function syntax

Excel's REPT function takes two arguments: the text to repeat, and the number of times to repeat it.

=REPT(text, number_times)

Example: =REPT("ha", 5) returns hahahahaha. The result is a single cell containing the repeated text — not 5 separate cells.

Practical examples

The most common uses:

  • Star ratings: =REPT("★", 4) & REPT("☆", 1) gives ★★★★☆ for a 4-out-of-5 rating
  • Bar chart in a cell: =REPT("|", A2) where A2 contains a number — produces an in-cell horizontal bar of that length
  • Padding numbers with leading zeros: =REPT("0", 5-LEN(A2)) & A2 for fixed-width formatting
  • Filling cells for test data: =REPT("test ", 100) generates a long string for paste testing

Limits and gotchas

Excel limits the output of REPT to 32,767 characters. If number_times × LEN(text) exceeds this, the formula returns #VALUE!. The function also returns an empty string if number_times is zero, and an error if it's negative.

For larger outputs, use our browser-based text repeater instead — it supports up to 100,000 repetitions and outputs that you can paste back into Excel as a value.

REPT vs. Power Query vs. our online tool

If you're working with a few hundred repetitions for a single cell, REPT is the fastest option. If you need to generate test data for many rows, Power Query's "Add Column" with a custom formula is more flexible. If you need a one-off long string for testing or pasting elsewhere, our online repeater is faster than spinning up Excel.

Common questions

Frequently asked.

32,767 characters. Beyond that you get a #VALUE! error.

Yes — Google Sheets has the same REPT function with identical syntax. We have a dedicated guide for Google Sheets.

You include the separator in the text itself. For comma-separated, use =REPT("hello, ", 5) which gives hello, hello, hello, hello, hello, (with a trailing comma you may want to trim).

Yes. =REPT(A1, B1) repeats whatever's in A1 the number of times given in B1.

Related reading

More articles.

Excel's REPT function

Excel repeats text with =REPT(text, number_times) — for example =REPT("ab", 5) gives ababababab. Include a separator inside the string if you need one, like =REPT("x, ", 10). The result cannot exceed 32,767 characters, or REPT returns a #VALUE! error, per the Microsoft REPT documentation.

Fill many rows or cells

To put the same value in many cells, type it once and drag the fill handle, or double-click the handle to fill down a contiguous column. For a set number of repeated rows (rather than characters in one cell), generate them in the line repeater and paste, or write a short VBA loop.

REPT vs. a text repeater

REPT is perfect for building bars and padding inside a sheet (a classic trick is in-cell bar charts). But when you want repeated text to paste elsewhere with newlines, numbering, or an exact byte size, the textrepeat.net repeater and stress test generator are the faster tools.