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

Free Excel barcode template.xlsx, 42 KB

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 template

Barcode 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.

BarcodeWhat you needFont for column B
Code 39One short formula: ="*"&UPPER(A2)&"*"Libre Barcode 39 Text
Code 128Two formulas (one calculates the checksum)Libre Barcode 128 Text
EAN-13Two formulas (one adds the check digit)Libre Barcode EAN13 Text
UPC-ASame as EAN-13, with a leading zeroLibre Barcode EAN13 Text
AB
1ValueBarcode
2SKU-10045*SKU-10045*
3BarcodeFontÌBarcodeFontQÎ
45901234123455JKLCDO*bcdefh+
Code 39, Code 128 and EAN-13 made with the formulas on this page. These are real barcodes set in the fonts. On most screens you can scan them with your phone.

Step 1: Install the free barcode fonts

  1. Download the fonts from the barcode fonts page. The ZIP contains all of them.
  2. Install them: on Windows, double-click each .ttf file and click Install. On a Mac, double-click it and click Install in Font Book.
  3. 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)&"*"
  1. Put your values in column A, starting in A2.
  2. Paste the formula into B2 and fill it down (double-click the small square at the bottom right of the cell).
  3. Select column B and set the font to Libre Barcode 39 Text, size 36 or larger.
  4. 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))
  1. Paste both formulas, then select B2:C2 and fill them down.
  2. Set column B to Libre Barcode 128 Text, size 36 or larger.
  3. 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:

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)&"+")
  1. 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.
  2. Type 12 digits in A2. For example, 590123412345 becomes 5901234123457.
  3. Paste both formulas and fill them down.
  4. 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

FontFont sizeNotes
Libre Barcode 39 Text36 pt or largerLonger values make wider barcodes, so widen the column.
Libre Barcode 128 TextAt least 24 pt, 36 pt recommendedAt 24 pt the narrowest bar is about 0.25 mm. Smaller bars are hard for many scanners to read.
Libre Barcode EAN13 TextAbout 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.

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?

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.