REPT in Excel: Simple In-Cell Bar Charts
By ExcelReady TeamUpdated 6 min read
The short answer
REPT repeats text a number of times: =REPT("|",5) returns |||||. To draw an in-cell bar chart, repeat a character in proportion to each value, such as =REPT("|",B2/1000) for one bar per 1,000. Scale long bars with =REPT("|",ROUND(B2/MAX($B$2:$B$7)*20,0)) so the largest value gets 20 characters.
Key takeaways
- =REPT(text, number_times) repeats text; decimals in number_times are cut off, not rounded.
- Divide the value by a step (like 1000) or scale it against MAX to keep bars a sensible length.
- Join two REPTs with & for progress bars: filled characters, then empty ones.
- A narrow character such as | gives smooth bars; set the font colour to style them.
- Conditional Formatting Data Bars are the built-in alternative when you don't need text.
On this page+
The Excel REPT function repeats a piece of text a set number of times, and that simple job makes it a quick way to draw bar charts inside cells. =REPT("|",B2/1000) turns a sales figure into a row of bars you can read at a glance. This guide is for anyone who wants a visual summary in a table, a progress tracker or a report without building a chart.
What does the Excel REPT function do?#
REPT returns text repeated as many times as you say.
=REPT(text, number_times)| Formula | Result |
|---|---|
=REPT("ab",3) | ababab |
=REPT("|",5) | ||||| |
=REPT("★",4) | ★★★★ |
=REPT("|",3.9) | ||| |
=REPT("|",0) | (empty text) |
Two rules to remember:
- Decimals are cut off. REPT keeps only the whole number part of
number_times, so 3.9 gives 3 repeats. Use ROUND when you want 3.9 to count as 4. - The result is text. It lines up with the rest of the row, but you can't add it up.
REPT works in every version of Excel, including Excel for Mac and Excel for the web.
How to make an in-cell bar chart with REPT#
Repeat a narrow character once for every step of the value. Here are five reps' sales:
| A | B | C | |
|---|---|---|---|
| 1 | Rep | Sales | Bar |
| 2 | Ava | 12,000 | |||||||||||| |
| 3 | Ben | 18,500 | |||||||||||||||||| |
| 4 | Cara | 7,400 | ||||||| |
In C2, type:
=REPT("|",B2/1000)Each 1,000 in sales adds one bar. 12,000 gives 12 bars, and 18,500 gives 18 (the half is dropped). Fill down with Ctrl+D on Windows or ⌘D on a Mac, and the column becomes a simple horizontal bar chart.
Make the bars look better#
A few formatting tweaks make a big difference:
- Set the font colour of column C to a strong colour, such as blue or green.
- Left-align the column so all bars start at the same edge.
- Try other characters. A full block (█) gives solid bars; in Excel 2013 and later you can produce it with
=REPT(UNICHAR(9608),B2/1000). - Shrink the font size of the bar column if the bars get too long.
How to scale bars to a fixed width#
Divide each value by the largest one to keep the longest bar at a set length, however big the numbers are:
=REPT("|",ROUND(B2/MAX($B$2:$B$6)*20,0))How it works:
B2/MAX($B$2:$B$6)gives each value as a share of the largest, from 0 to 1.*20makes the largest value 20 characters long.- ROUND turns the share into a whole number of bars.
For Ben, 18,500 ÷ 21,000 × 20 is 17.6, which rounds to 18 bars, while Dev, the top seller, gets the full 20. Lock the range with dollar signs before filling down, so every row compares against the same maximum. This version keeps working when sales grow from thousands to millions, while the /1000 version would start drawing hundreds of bars.
How to show the number next to the bar#
Join the bar and the value with &. The joining text guide covers & in detail.
=REPT("|",B2/1000)&" "&TEXT(B2,"#,##0")For Ava, this shows 12 bars followed by 12,000. TEXT formats the number with a thousands separator, because joining a raw number would show 12000.
How to build a progress bar#
Join two REPTs: one for the completed part and one for the rest. With a percentage complete in B2 (for example 0.3 for 30%):
=REPT("■",ROUND(B2*10,0))&REPT("□",10-ROUND(B2*10,0))At 30%, this returns ■■■□□□□□□□: three filled squares and seven empty ones, always 10 in total. It works well in project trackers and task lists. Add &" "&TEXT(B2,"0%") to show the percentage after the bar.
Other uses: star ratings and padding#
REPT is useful wherever you need repeated characters:
| Task | Formula | Result for 4 |
|---|---|---|
| Star rating out of 5 | =REPT("★",B2)&REPT("☆",5-B2) | ★★★★☆ |
| Leading zeros to 6 digits | =REPT("0",6-LEN(B2))&B2 | 000004 |
| Dot leaders in a list | =A2&REPT(".",20-LEN(A2)) | name followed by dots |
For leading zeros, =TEXT(B2,"000000") gives the same result and is easier to read; REPT is handy when the value is already text. REPT also pairs well with REPLACE to hide part of an ID, as shown in our guide to SUBSTITUTE and REPLACE.
REPT vs Conditional Formatting Data Bars#
Excel has a built-in way to draw bars inside cells. Select the numbers, then choose Home > Conditional Formatting > Data Bars and pick a style. The bar appears behind the number in the same cell.
| REPT bars | Data Bars | |
|---|---|---|
| Needs a formula | Yes | No |
| Bar in a separate cell | Yes | No, behind the number |
| Combine with text | Yes, with & | No |
| Smooth, exact lengths | No, whole characters | Yes |
| Works in every version | Yes | Yes (Excel 2007 and later) |
Use Data Bars for a polished report. Use REPT when you want the bar in its own column, need to join it with text, or want a trick that also works in a plain-text export.
Common REPT mistakes#
These are the problems people run into:
- Bars that run off the screen. The values are too big. Divide by a larger step or scale with MAX.
- #VALUE! In Excel, a negative
number_timesor a result over 32,767 characters returns #VALUE!. Check for negative values or wrap them in MAX(0, …). - Uneven bars. Proportional fonts make some characters wider. Use the same character in every row.
- Forgetting the quotes. The text to repeat must be in double quotes:
"|".
If you want to split text apart rather than build it up, TEXTSPLIT splits a cell into columns, and LEFT, RIGHT and MID take out part of a cell.
Practise it#
Try the bar chart exercise on this page. Then open the joining text lesson to practise &, CONCAT and TEXTJOIN in a live spreadsheet; the TEXTJOIN function guide explains its delimiter and ignore_empty options, and CONCATENATE vs CONCAT vs TEXTJOIN helps you pick the right one.
Try it yourself
This is a live spreadsheet. Type the formula in the green cell and press Enter.
Draw a bar for each rep's sales: one | for every 1,000. In C2, use REPT to repeat "|" B2/1000 times.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Bar | |||
| 2 | ||||
| 3 | ||||
| 4 | ||||
| 5 | ||||
| 6 | ||||
| 7 | ||||
| 8 | ||||
| 9 |
Tip: REPT takes the text to repeat in double quotes, then how many times. Here that is B2 divided by 1000.
Practise this in a lesson
Frequently asked questions
What does REPT do in Excel?
REPT repeats a piece of text a given number of times. =REPT("ab",3) returns ababab. It works in every version of Excel.
What happens if number_times is a decimal?
REPT drops the decimal part, so =REPT("|",3.9) returns three bars, not four. Wrap the number in ROUND if you want normal rounding.
How do I make an in-cell bar chart without REPT?
Select the numbers and choose Home > Conditional Formatting > Data Bars. Excel draws a bar inside each cell behind the number, with no formula.
Why does REPT return #VALUE!?
In Excel, REPT returns #VALUE! when number_times is negative or the result would be longer than 32,767 characters. Check the value you repeat by and scale it down.