REPT Function in Microsoft Excel: Examples, Pitfalls & Compatibility
REPT in Microsoft Excel: repeat a text unit to build a short display bar, separator or padded label. Includes worked examples and application-specific cautions.
Verification status: Official documentation referenced; example outcomes independently reasoned or arithmetically checked where stated. Not executed in Microsoft Excel. How formula examples are checked
Quick answer: Use REPT in Microsoft Excel to repeat a text unit to build a short display bar, separator or padded label. The official REPT reference is the source for the function definition and platform-specific rules described below.
Syntax and arguments
=REPT(text, number_times)
text (required): The exact text unit, including any intended separator.
number_times (required): A nonnegative repeat count. Prefer an explicitly validated whole number.
Examples use English function names, comma argument separators and decimal points. Adapt formula separators to your workbook settings, not punctuation inside quoted text.
When to use it
Use REPT for a compact visual cue or controlled text padding. Keep the original numeric value visible as well: a bar is a presentation aid, not a replacement for the data. Long repeated strings make worksheets difficult to use.
Three worked examples
Each example is independent. Where input cells are listed, enter those values first; otherwise the formula is self-contained. Expected outputs are independently checked calculations or documented error expectations, not captured results from Microsoft Excel.
Example 1: Make a five-unit bar
=REPT("|",5)
Expected result: "|||||" (quoted here to make spaces and text boundaries visible).
The five vertical bars form a display indicator; retain the numeric value 5 beside it.
Example 2: Repeat a token with spacing
=REPT("OK ",3)
Expected result: "OK OK OK " (quoted here to make spaces and text boundaries visible).
The trailing space is part of each unit, including the last one.
Example 3: Check a zero-repeat result
=LEN(REPT("X",0))
Expected result: 0.
REPT produces empty text and LEN confirms that its length is zero. This is not a demonstration that the formula cell itself is blank.
Put it to work safely
Set a documented display scale and maximum count before generating bars. A count of five should mean the same thing throughout the column. Include a separator inside the repeated text when needed; REPT does not add spaces for you. Avoid hiding materially different quantities behind the same clipped bar without also displaying the actual values.
Common mistakes and fixes
Repeated words run together. The text unit is repeated exactly. Add a space inside the quoted text when separation is required.
A zero count seems to have deleted the result. Zero repetitions produce empty text, not a numerical zero. A cell with a formula returning empty text is not necessarily a truly empty cell.
A large count fails or makes the sheet unwieldy. Validate counts and keep display strings short. The application-specific length rules should not be assumed identical.
Microsoft Excel-specific notes
Microsoft documents truncation of a noninteger repeat count, an empty string for zero, and a maximum result length of 32,767 characters. Validate counts before the call instead of relying on silent truncation. See the vendor reference for the current definition.
Excel and Google Sheets comparison
Small, nonnegative whole-number examples are suitable comparison cases. Result-length ceilings and fractional or invalid counts must be checked separately when exporting a workbook.
Compare the REPT guide for Google Sheets and its official documentation. Having a guide in both libraries establishes two documented references, not a certificate of identical behavior across releases, locales or file conversions.
Related guides
LEN, LEFT, TEXT, IF · All Microsoft Excel functions.
Evidence and testing scope
Editorial verification: Official references retrieved on 2026-10-12. The three worked cases are included in this release’s reproducible Python checking suite. It checks the stated arithmetic, calendar or text model and the expected documented error classification; it is not the Microsoft Excel calculation engine. No native application run, UI screenshot, maximum-size benchmark or cross-version certification is claimed. Review the editorial testing standards before relying on a formula in a critical workbook.