How to make barcodes in Excel
Install a free barcode font, convert each value with a formula, then set the cell to the barcode font. This works for Code 39, Code 128, EAN-13 and UPC-A in Excel for Windows and Mac, with no add-ins or macros.
Updated
Ready-made sheets for Code 39, Code 128, EAN-13 and UPC-A, with all formulas set up for 100 rows. Type your values in column A and the barcodes appear next to them. Works in any language version of Excel.
Download the templateBarcode formulas for Excel at a glance
Your value is in cell A2 and the formula goes in B2. Set B2 to the font in the last column.
| Barcode | What you need | Font for column B |
|---|---|---|
| Code 39 | One short formula: ="*"&UPPER(A2)&"*" | Libre Barcode 39 Text |
| Code 128 | Two formulas (one calculates the checksum) | Libre Barcode 128 Text |
| EAN-13 | Two formulas (one adds the check digit) | Libre Barcode EAN13 Text |
| UPC-A | Same as EAN-13, with a leading zero | Libre Barcode EAN13 Text |
| A | B | |
|---|---|---|
| 1 | Value | Barcode |
| 2 | SKU-10045 | *SKU-10045* |
| 3 | BarcodeFont | ÌBarcodeFontQÎ |
| 4 | 590123412345 | 5JKLCDO*bcdefh+ |
Step 1: Install the free barcode fonts
- Download the fonts from the barcode fonts page. The ZIP contains all of them.
- Install them: on Windows, double-click each
.ttffile and click Install. On a Mac, double-click it and click Install in Font Book. - Close Excel completely and open it again. The fonts now appear in the font list. If the fonts do not appear or you are using the web version of excel, try entering the font's complete name and pressing ENTER.
The fonts are free for commercial use. Until they're installed, the barcode cells show letters and symbols such as *SKU-10045* or 5JKLCDO*bcdefh+ instead of bars. That's normal: the barcode font turns those characters into bars.
Code 39 in Excel
Code 39 is the easiest barcode to make in Excel. A Code 39 barcode starts and ends with an asterisk, so the formula only adds those:
="*"&UPPER(A2)&"*"- Put your values in column A, starting in A2.
- Paste the formula into B2 and fill it down (double-click the small square at the bottom right of the cell).
- Select column B and set the font to Libre Barcode 39 Text, size 36 or larger.
- Widen column B and increase the row height until the whole barcode is visible.
UPPER converts lowercase letters to capitals. Standard Code 39 can only encode uppercase A–Z, digits 0–9, and the symbols - . $ / + % and space.
If your values contain spaces
A plain space shows up as a gap in Excel, which breaks the barcode. The barcode font draws the Code 39 space when it gets the character  instead, so this version of the formula swaps spaces for it:
=IF(A2="","","*"&SUBSTITUTE(UPPER(A2)," ",UNICHAR(194))&"*")It also leaves B2 empty when A2 is empty. It needs Excel 2013 or newer because of UNICHAR.
Code 128 in Excel
Code 128 makes shorter barcodes than Code 39 and supports lowercase letters and all common symbols. It's harder to set up because every barcode needs a start character, a checksum calculated from the text, and a stop character. Typing your text in a Code 128 font without them gives a barcode that looks right but never scans.
These two formulas do the encoding. The first calculates the checksum in a helper column C, and the second builds the barcode text in column B:
Cell C2 (checksum helper)
=IF(A2="","",MOD(104+SUMPRODUCT((CODE(MID(A2,ROW(INDIRECT("1:"&LEN(A2))),1))-32)*ROW(INDIRECT("1:"&LEN(A2)))),103))Cell B2 (barcode)
=IF(A2="","",UNICHAR(204)&SUBSTITUTE(A2," ",UNICHAR(194))&UNICHAR(C2+IF(C2=0,194,IF(C2<95,32,100)))&UNICHAR(206))- Paste both formulas, then select B2:C2 and fill them down.
- Set column B to Libre Barcode 128 Text, size 36 or larger.
- Keep column C. You can hide it, but don't delete it.
The barcodes update automatically when a value in column A changes. A few things to know:
- The formulas work in Excel 2013 or newer, on Windows and Mac. In older versions,
UNICHARshows a#NAME?error. - They encode every value in Code 128's standard character set, which supports all regular letters, digits and symbols. Accented letters and emoji aren't supported.
- For long numbers, the Code 128 encoder makes slightly shorter barcodes, because it packs two digits into each symbol. Its List for Excel mode converts a whole column at once. Use it if your barcodes need to be as compact as possible or your Excel is older than 2013.
EAN-13 in Excel
The EAN-13 font is normally used by typing 12 digits and a question mark, and the font draws the bars and the check digit. That shortcut relies on an OpenType font feature called contextual alternates. Web browsers apply it automatically and Word can after you switch it on, but Excel doesn't support it. In Excel, the same input shows the digits between thin lines with a question mark at the end, and it doesn't scan.
The font also accepts a second input format that doesn't need any font features. In it, each digit becomes a letter according to the standard EAN-13 encoding pattern. The formulas below create that format. First, column C adds the check digit to your 12-digit number, or checks it if you entered all 13 digits:
Cell C2 (full number with check digit)
=IF(A2="","",IFERROR(IF(LEN(A2)=12,A2&MOD(10-MOD(SUMPRODUCT(--MID(A2,{1,3,5,7,9,11},1))+3*SUMPRODUCT(--MID(A2,{2,4,6,8,10,12},1)),10),10),IF(LEN(A2)=13,IF(--RIGHT(A2)=MOD(10-MOD(SUMPRODUCT(--MID(LEFT(A2,12),{1,3,5,7,9,11},1))+3*SUMPRODUCT(--MID(LEFT(A2,12),{2,4,6,8,10,12},1)),10),10),A2,"Wrong check digit"),"Wrong number of digits")),"Digits only"))Cell B2 (barcode)
=IF(OR(LEN(C2)<>13,ISERROR(--C2)),"",LEFT(C2)&CHAR(MID(C2,2,1)+65)&CHAR(MID(C2,3,1)+IF(MID("AAAAAAAABABBAABBABAABBBAABAABBABBAABABBBAAABABABABABBAABBABA",LEFT(C2)*6+2,1)="A",65,75))&CHAR(MID(C2,4,1)+IF(MID("AAAAAAAABABBAABBABAABBBAABAABBABBAABABBBAAABABABABABBAABBABA",LEFT(C2)*6+3,1)="A",65,75))&CHAR(MID(C2,5,1)+IF(MID("AAAAAAAABABBAABBABAABBBAABAABBABBAABABBBAAABABABABABBAABBABA",LEFT(C2)*6+4,1)="A",65,75))&CHAR(MID(C2,6,1)+IF(MID("AAAAAAAABABBAABBABAABBBAABAABBABBAABABBBAAABABABABABBAABBABA",LEFT(C2)*6+5,1)="A",65,75))&CHAR(MID(C2,7,1)+IF(MID("AAAAAAAABABBAABBABAABBBAABAABBABBAABABBBAAABABABABABBAABBABA",LEFT(C2)*6+6,1)="A",65,75))&"*"&CHAR(MID(C2,8,1)+97)&CHAR(MID(C2,9,1)+97)&CHAR(MID(C2,10,1)+97)&CHAR(MID(C2,11,1)+97)&CHAR(MID(C2,12,1)+97)&CHAR(MID(C2,13,1)+97)&"+")- Before typing your numbers, select column A and set its format to Text (Home > Number format > Text). Otherwise Excel removes leading zeros and shows long numbers as
5.90123E+12. - Type 12 digits in A2. For example,
590123412345becomes5901234123457. - Paste both formulas and fill them down.
- Set column B to Libre Barcode EAN13 Text, about 80 pt (see printing sizes).
If the number is wrong, column C says Wrong check digit, Wrong number of digits or Digits only, and column B stays empty so you can't print a bad barcode by accident. The digits printed under the bars are part of the font, so they always match the bars.
To sell products in shops, the number itself must be registered to your company with GS1. The formula draws a correct barcode for any number, but retailers only accept registered ones. For internal use, numbers starting with 2 are reserved for in-store use.
UPC-A in Excel
A UPC-A barcode has the same bars as an EAN-13 barcode with a 0 in front. To make UPC-A barcodes, use the EAN-13 formula for column B and this version for column C, then type 11 digits (or all 12) in column A:
=IF(A2="","",IFERROR(IF(LEN("0"&A2)=12,"0"&A2&MOD(10-MOD(SUMPRODUCT(--MID("0"&A2,{1,3,5,7,9,11},1))+3*SUMPRODUCT(--MID("0"&A2,{2,4,6,8,10,12},1)),10),10),IF(LEN("0"&A2)=13,IF(--RIGHT("0"&A2)=MOD(10-MOD(SUMPRODUCT(--MID(LEFT("0"&A2,12),{1,3,5,7,9,11},1))+3*SUMPRODUCT(--MID(LEFT("0"&A2,12),{2,4,6,8,10,12},1)),10),10),"0"&A2,"Wrong check digit"),"Wrong number of digits")),"Digits only"))Scanners read the bars as your UPC-A number. The text under the bars follows the EAN-13 layout, with the leading 0 shown. If your packaging needs the exact UPC-A text layout, create the barcode as an image with the barcode generator instead.
Formulas show an error after pasting?
Excel uses different formula separators in some languages. If your Excel uses semicolons (;) instead of commas, or shows function names in your language, a pasted formula is rejected. The easiest fix is the template: formulas saved in a file work in every language version of Excel. You can also copy the formula cells from the template into your own workbook.
Printing barcodes from Excel
| Font | Font size | Notes |
|---|---|---|
| Libre Barcode 39 Text | 36 pt or larger | Longer values make wider barcodes, so widen the column. |
| Libre Barcode 128 Text | At least 24 pt, 36 pt recommended | At 24 pt the narrowest bar is about 0.25 mm. Smaller bars are hard for many scanners to read. |
| Libre Barcode EAN13 Text | About 80 pt (64–160 pt) | At 80 pt the bars are about 31 mm wide, the standard 100% size. Retail scanners are designed for 80% to 200% of it. |
- Print at 100% scale. In Page Layout, set Scale to Fit to 100%. "Fit sheet on one page" shrinks everything, including the bars.
- Make sure nothing is cut off. If the column is too narrow, the barcode is clipped at the cell edge and won't scan. Leave some empty space on both sides of the bars.
- Use black on white. Don't color the barcode cells or put a pattern behind them.
- Print only what you need. To print just the filled rows, select them and choose Print Selection.
- Test first. Print one page and scan it with the scanner or phone app you'll actually use before printing a batch.
Sharing a file with barcodes
Excel files don't include the fonts they use. Anyone who opens your file needs the barcode fonts installed, or they'll see letters and symbols instead of bars. To send barcodes to someone who doesn't have the fonts, save the sheet as a PDF (File > Save As > PDF). The PDF contains the fonts, and the license allows this.
Excel barcode not working?
- Letters and symbols instead of bars: the font isn't installed or isn't applied. Install it, restart Excel, and set the barcode column to the font.
#NAME?error: your Excel is older than 2013, or the formula was pasted into Excel set to a different language. Use the template or the Code 128 encoder.- Barcode doesn't scan: check that the barcode isn't cut off by the column edge, the font size is large enough, and the page prints at 100%. For Code 128, never edit the encoded text by hand: change the value in column A instead.
- EAN-13 shows digits between thin lines and a question mark: you typed 12 digits and a question mark directly into a cell. That input only works in Word and browsers. Use the two EAN-13 formulas above.
- Leading zeros disappear: format column A as Text before typing the numbers, then type them again.
- Code 39 scans as strange characters: your scanner is set to "Full ASCII" mode, where
$,+,/and%followed by a letter mean special characters. Turn that mode off, or avoid those symbols.
Do I need an add-in or macros?
No. Everything on this page uses normal formulas and free fonts, so there's nothing to install apart from the fonts and no security warnings for macros. The template is a regular .xlsx file. The same formulas also work in LibreOffice Calc.
If you need a barcode as an image file instead, for a website or a label design, use the barcode generator. For documents, see all barcode fonts.