- Create GS1-128 and GS1-DataMatrix barcodes in Excel;
- Easy-to-use manual and advanced barcode programming examples;
- No fonts are required.
GS1 Barcodes (GS1-128 and GS1-DataMatrix) in Excel
An example how to insert linear and 2D GS1 barcodes (GS1-128 & GS1-DataMatrix) in Excel with StrokeScribe barcode generator with simple steps.
The first method of making GS1 barcodes (both GS1-128 and GS1-DataMatrix) in Excel is to insert the barcode generator as an Active Document and manually set the GS1 data string. This method of making GS1 barcodes is useful when you need a single barcode.
The second method to make GS1 barcodes - is to use formula and a small VBA script. This method allows to generate GS1-128 and GS1-DataMatrix in bulk quantities. These barcodes are hi-resolution scalable vector pictures.
Requirements
- Download and install the barcode generator
Placing GS1 barcode as an Active Document
Use this method when you need a single simple GS1 barcode with manual data entry. This method does not require programming.
1. Switch to the Insert tab on the Ribbon and click Object.

2. Look for the StrokeScribe Document in the list:
3. Right-click the barcode object, select StrokeScribe Control->Properties from the context menu.

- Switch to the General tab;
- Set Alphabet = EAN128 or GS1DATAMATRIX;
- Check the Process tilde option;
- Enter the barcode data into the Text field. For example: 10123456~d029112501303101000055

In this text string, we encode a batch number (AI 10), a FNC1 code (~d029), a production date (AI 11) and a product net weight (AI 310Y):
10123456~d029112501303101000055For the GS1 data format explanation, look in the tutorials below.
Because the batch number is a variable-length value, we put a FNC1 code after it.
The production date format is YYMMDD. So the 250130 is decoded as 30-Jan-2025.
The decimal point position indicator Y in the product net weight (AI 3101Y) is encoded as shown:
- 3100000055 = 55Kg
- 3101000055 = 5.5Kg
- 3102000555 = 5.55Kg
- 3101000555 = 55.5Kg
- 3103555555 = 555.555Kg
Placing GS1 barcodes in Excel with formula
Making GS1 barcodes with formula is useful for bulk barcode generation. First, we write a small VBA script that call the barcode generator and produces a barcode picture in a temporary file in vector forman and then we load the barcode picture into a cell.
Second, we write a formula that calls the VBA script and provides the script with the cell's name. This method fits the barcode into a cell and works both with single and merged cells.
Unlike the most barcoding add-ons, this method refreshes the barcodes automatically when the spreadsheet content is changed and it is completely offline.
Step 1. Open the VBA window (Alt+F11) and create a standard module (VBAProject->Insert->Module).
Step 2. Paste the following code into the module:
Step 2.1. Choose between GS1-128 and GS1-DataMatrix barcode generation by modifying the Alphabet property in the code.
Step 3. Add a reference to the StrokeScribe Class into your VBA project.
Step 4. Switch back to the Excel window. Paste the following formula into the cell A1:
= "10123456" & CHAR(29) & "11250130" & "3101000055"
As in previous example, we encode the same GS1 values in the barcode: a batch number (AI 10), a FNC1 code (~d029), a production date (AI 11) and a product net weight (AI 310).
For the GS1 data format explanation, look in the tutorials below.

Step 5. Paste this formula into a cell that is large enough to fit the barcode:
=CreateBarcodeGS1(A1)

Encoding numeric values in GS1 barcodes
As you see, values like weight, length, volume do not have decimal point. Regular numbers from a spreadsheet need to be converted to GS1 format.
Paste the following function into the VBA module and then use it to convert numbers:
Public Function Y6N(txt)
p = InStr(txt, ".")
If p > 0 Then p = Len(txt) - p
txt = Replace(txt, ".", "")
v = Format$(txt, "000000")
y = Format$(p, "0")
Y6N = y + v
End Function
An example of product net weight (AI 3101Y) conversion:
=CreateBarcodeGS1("310" & Y6N("123.456"))
These GS1 barcoding examples are compatible with all Excel versions: Excel 365, 2019, 2016, 2013, 2010 and XP;
High quality, scalable barcodes without fonts;
Compatible with GS1 general barcode specification.