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: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: REPT repeats the supplied text unit, including its spaces. Excel documents truncation of a fractional count, empty text for zero and #VALUE! if the resulting string exceeds 32,767 characters. Keep display bars tied to an explicit numeric scale.
Availability and version history
- Introduced: Introduction version not established by the official history reviewed.
- Availability: Official help lists Excel for Microsoft 365, Excel for Microsoft 365 for Mac, Excel 2024, Excel 2024 for Mac, Excel 2021, Excel 2021 for Mac, Excel 2019, Excel 2016.
- Checked: October 14, 2026; official REPT reference. Documentation check, not a new native test; existing example-verification notes retain their scope.
Syntax and arguments
=REPT(text, number_times)
Both arguments are required. The text argument is the complete unit to repeat; the count is how many copies to concatenate. Microsoft’s argument description calls the count positive, while its remarks explicitly support zero. The worked controls use nonnegative numeric counts.
The source says noninteger counts are truncated. A positive count of 3.9 therefore repeats three times, rather than rounding to four. Negative, Boolean, numeric-text and source-error conversion rules are not assigned undocumented error codes in this review.
Use English function names and comma separators, adapting separators to the workbook locale. Quotation marks around expected strings below are explanatory; they are not extra characters returned by REPT. These are independent string models, not native Excel output captures.
Original example 1: make a five-unit bar
=REPT("|",5)
Expected output: "|||||". Keep the original number 5 beside the display. The repeated character does not carry its own unit, scale or meaning.
Original example 2: repeat a spaced token
=REPT("OK ",3)
Expected output: "OK OK OK ". The trailing space belongs to each repeated unit, including the last. The result has nine ASCII characters, not eight.
Compare =REPT("OK",3), which gives "OKOKOK", length six. REPT does not insert separators automatically, and repeated text is not a substitute for a delimiter-aware joining rule.
Original example 3: zero repetitions
=LEN(REPT("X",0))
Expected output: 0. REPT returns empty text; LEN reports its length. That result is neither the numeric value zero stored by REPT nor proof that the formula’s cell is physically empty.
Example 4: inspect count truncation
For the unit ab, compare counts 0,1,2.9 and 3.9. Expected strings are empty text, ab, abab and ababab, with lengths 0,2,4 and 6.
If the count must be an integer business quantity, validate it instead of accepting silent truncation. For a separately validated numeric count in A2, =AND(A2>=0,A2=INT(A2)) tests a nonnegative-whole-number policy. Inputs 0 and 3 pass; 3.9 and −1 fail. Type validation remains a separate step.
Advanced example: build a capped bar without hiding the amount
Suppose validated nonnegative amounts 0, 9, 10, 27 and 65 appear in A2:A6. Use one bar character for each complete block of ten, with at most five characters:
=REPT("|",MIN(5,INT(A2/10)))
Filled down, expected bar lengths are 0,0,1,2 and 5. The corresponding visible strings are empty, empty, |, || and |||||.
Keep the original amounts visible. Both 65 and 100 would reach the five-character cap even though they differ materially. Add a separate status such as =IF(A2>50,"Above display cap",""); 65 receives that label, while 27 does not. The bar is a presentation device, not rounding or alteration of the source amount.
Advanced example: pad a short text identifier
For validated digit strings in A2, pad to a minimum width of five characters without truncating longer strings:
=REPT("0",MAX(0,5-LEN(A2)))&A2
Enter the inputs as text, preserving any leading zeros. Strings 7, 482, 12345 and 123456 become 00007, 00482, 12345 and 123456. Lengths are 5,5,5 and 6. The last remains six characters because this policy is a minimum width, not an exact-width validator.
If a receiving system requires exactly five digits, reject overlength or nondigit inputs separately. Padding should not silently discard a meaningful prefix or convert text identifiers into arithmetic values.
Advanced check: calculate a safe output length
For these ASCII controls, output length is the unit length multiplied by the truncated nonnegative count. A two-character token repeated 16,383 times has length 32,766. Repeating it 16,384 times would have length 32,768, exceeding Microsoft’s documented limit and producing #VALUE!.
A one-character token repeated 32,767 times reaches the documented boundary. These are size-rule calculations, not maximum-size execution benchmarks. Multibyte storage size, supplementary Unicode characters, variation selectors and compatibility-version character counting require separate tests; do not infer them from the ASCII examples.
Practical checks and comparison
Use LEN to inspect ordinary string length, but retain exact whitespace when checking a repeated token. A zero-length output can be expected, so do not automatically replace every empty-looking result with an error label.
Avoid generating very long bars when a short scale or a chart communicates the same quantity better. Font choice and cell width determine what is visible; the formula’s returned character count does not guarantee that every repeated character is displayed.
Compare the Google Sheets REPT guide for its separately documented count and size rules. Shared small ASCII examples do not certify identical limits, coercions or Unicode handling across programs and releases.
Related guides
LEN, LEFT, TEXT, IF · All Microsoft Excel functions.
Editorial verification: Full manuscript and dedicated Microsoft reference reviewed on October 14, 2026. Original title, publication date, worked formulas and input fixtures are preserved. Expectations were independently calculated from explicit text, array or row-selection models; no native Excel execution, visibility interaction, maximum-size benchmark or file-interchange test was performed.