REPT Function (LibreOffice Calc)
The REPT function in LibreOffice Calc repeats a text string a specified number of times. It is essential for padding, visualization, fixed-width formatting, and building lightweight text-based charts.
This guide provides syntax, examples, edge cases, and best practices, making it one of the most complete REPT references available for LibreOffice Calc.
What the REPT Function Does
- Repeats a text string N times
- Useful for padding and alignment
- Useful for bar charts and progress indicators
- Works with text, numbers (converted to text), and formulas
- Supports dynamic repetition counts
It is designed to be simple, flexible, and surprisingly powerful.
Syntax
REPT(text; number_times)
Arguments
-
text:
The text string to repeat. -
number_times:
The number of repetitions (must be ≥ 0).
Basic Examples
Repeat a character 5 times
=REPT("*"; 5)
Returns "*****".
Repeat a word
=REPT("Hi "; 3)
Returns "Hi Hi Hi ".
Repeat a number (converted to text)
=REPT(7; 4)
Returns "7777".
Repeat a space for padding
=REPT(" "; 10)
Advanced Examples
Create a simple bar chart
=REPT("█"; A1)
Create a progress bar (0–100%)
=REPT("█"; A1/10)
(Assumes A1 is 0–100.)
Create a fixed-width padded label
=CONCAT(A1; REPT(" "; 20 - LEN(A1)))
Create a left-padded number
=CONCAT(REPT("0"; 5 - LEN(A1)); A1)
Create a rating indicator
=CONCAT(REPT("★"; A1); REPT("☆"; 5 - A1))
Create a visual heat bar
=REPT("▓"; ROUND(A1 * 10))
Create a dotted leader for tables
=CONCAT(A1; REPT(". "; 30 - LEN(A1)); B1)
Create indentation
=CONCAT(REPT(" "; B1); A1)
Create a histogram row
=REPT("|"; A1)
Create a bullet list with indentation
=CONCAT(REPT(" "; B1 * 2); "• "; A1)
Create a dynamic underline
=REPT("─"; LEN(A1))
Create a masked string
=REPT("*"; LEN(A1))
Edge Cases and Behavior Details
number_times < 0 → Err:502
=REPT("A"; -1)
number_times = 0 → returns empty string
=REPT("A"; 0) → ""
number_times is fractional → truncated
=REPT("A"; 3.9) → "AAA"
text is empty → returns empty string
=REPT(""); 10 → ""
text is a number → converted to text
=REPT(5; 3) → "555"
REPT of an error propagates the error
=REPT(#N/A; 3) → #N/A
Maximum output length
LibreOffice limits cell text length (~1M characters).
REPT may return Err:512 if exceeded.
REPT does not trim or clean text
Use TRIM or CLEAN if needed.
Common Errors and Fixes
Err:502 — Invalid argument
Occurs when:
- number_times < 0
- number_times is non-numeric
- text is missing
REPT returns too many characters
Cause:
- number_times too large
- Unexpected LEN(text)
REPT returns nothing
Cause:
- number_times = 0
- text = ""
Best Practices
- Use REPT for padding, alignment, and fixed-width formatting
- Use REPT for lightweight bar charts and indicators
- Combine with LEN for dynamic padding
- Combine with CONCAT/TEXTJOIN for structured output
- Use REPT with TRIM/CLEAN for clean visualization
- Use REPT for masking and obfuscation
Related Patterns and Alternatives
- Use CONCAT and TEXTJOIN for assembly
- Use LEFT, RIGHT, MID for extraction
- Use SUBSTITUTE and REPLACE for editing
- Use LEN for dynamic repetition logic
- Use TRIM and CLEAN for normalization
By mastering REPT and its companion functions, you can build expressive, structured, and visually rich text‑based workflows in LibreOffice Calc.
Reproducible example (tested in LibreOffice Calc)
This standalone example was calculated in LibreOffice Calc 25.2.3.2 and matched the expected value. It is a practical cross-check of one usage, not proof that every example elsewhere on this page is correct.
=REPT("-";4)
Expected result: ----.
Repeat a text fragment a specified number of times.
If the result differs, check the referenced cells, argument separators and number formatting. For more information, consult the LibreOffice Calc official help.