Arte SheetsLearn. Try. Understand.

Text

REPT function: build in-cell progress bars and zero-pad fixed-width IDs

Repeat characters N times with REPT to render lightweight text bar charts or pad variable-length account numbers.

Two high-value uses: fixed-width zero padding and mini bars

REPT(text, number_times) repeats text a specified number of times. To pad invoice number 42 to 6 digits ("000042"), repeat "0" for 6 - LEN(42) = 4 times and append 42: REPT("0", 6 - LEN(A2)) & A2.

To draw a quick in-cell progress indicator on a 0..100 score, scale the score by 20: REPT("|", ROUND(B2 / 20, 0)) turns 80 into "||||".

RawID (A)CompletionPct (B)Padded 6-Digit IDProgress Bar
4280000042||||
10590001059(empty string)

Zero-pad numeric IDs reliably

Wrapping 6 - LEN(A2) with MAX(0, ...) ensures IDs that already reach 6+ digits never pass a negative count to REPT.

=REPT("0", MAX(0, 6 - LEN(A2))) & A2

Zero count returns "" while negative count returns #VALUE!

REPT("|", 0) returns an empty string "", whereas a negative number_times (such as when LEN exceeds target width without MAX(0,...)) returns #VALUE!.

=REPT("|", -1)

Try the example

Use the original values or change them to test your understanding.

Further reading