Text function

REPT function

Repeats a text a given number of times. Used for in-cell bar charts, star ratings and padding values with zeros.

Available in All versions of Excel, including Microsoft 365, Excel for Mac and Excel for the web

In every Excel versionWorks in Google Sheets

Syntax

REPT(text, number_times)
ArgumentWhat it means
textRequiredThe text to repeat, e.g. "*" or "0".
number_timesRequiredHow many times to repeat it. Decimals are truncated; 0 returns an empty string.

Returns: The repeated text.

How REPT works

REPT simply writes the same text several times in a row: =REPT("-",10) gives ten dashes. That sounds trivial, but it is the basis of several neat tricks: quick bar charts inside cells, star ratings, progress bars, and padding numbers with leading zeros to a fixed width.

The number of repetitions is truncated to a whole number, so REPT("|",7.9) gives 7 bars. Zero gives an empty string and a negative number gives #VALUE!. The result cannot be longer than 32,767 characters.

For in-cell charts, choose a character that is the same width every time (| or the block character UNICHAR(9608)) and a font such as Consolas, so bars of equal value line up.

Examples

1In-cell bar chart of sales

C2fx=REPT("|",B2/10)
ABC
1RepSales (k)
2Ana73|||||||
3Ben45

Result: |||||||

73/10 = 7.3, truncated to 7 bars. Fill down to get a quick visual comparison next to the numbers.

2Pad an ID with leading zeros

B2fx=REPT("0",6-LEN(A2))&A2
AB
1Employee no.
2742000742

Result: 000742

The number has 3 digits, so 3 zeros are added in front to make a 6-character ID. TEXT(A2,"000000") gives the same result.

3Star rating

C2fx=REPT("★",B2)&REPT("☆",5-B2)
ABC
1ProductRating
2Desk Lamp3★★★☆☆

Result: ★★★☆☆

Three filled stars followed by two empty ones make a 5-star scale.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 15 KB

Common errors and how to fix them

ErrorWhy it happensFix
#VALUE!number_times is negative, or the result would exceed 32,767 characters.Wrap the count in MAX(0, ...) and keep the result short.

Tips

  • Scale large numbers down before using them in REPT, otherwise a value of 25,000 tries to draw 25,000 characters.
  • Use UNICHAR to get special symbols for bars and ratings, e.g. UNICHAR(9608) for a solid block.
  • Conditional formatting data bars are a more polished alternative for dashboards, but REPT works in plain-text exports.

Google Sheets

REPT also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.

REPT in other languages

In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.

LanguageFunction name
CzechOPAKOVAT
DanishGENTAG
DutchHERHALING
FinnishTOISTA
GermanWIEDERHOLEN
HungarianSOKSZOR
ItalianRIPETI
Norwegian (Bokmål)GJENTA
PolishPOWT
Portuguese (Portugal)REPETIR
RussianПОВТОР
SpanishREPETIR
SwedishREP
TurkishYİNELE

Recipes that use REPT