Design and Print Barcode Labels Using Excel |
Part 7: Serial Numbers, Batch Codes, Variable Data Printing, and Traceability Labels |
1. Introduction to Variable Data Printing (VDP) and Traceability |
In Part 6, we explored standards-compliant barcodes for retail and global trade. In industrial and pharmaceutical applications, labels must often include serial numbers, batch codes, expiration dates, and other dynamic data. This requires variable data printing (VDP), where each label may have unique information. |
This part focuses on: |
1. Generating serial numbers and batch codes in Excel |
2. Combining variable data with barcodes |
3. Traceability labels for pharmaceuticals, food, and logistics |
4. Automation strategies for large-scale printing |
5. Data validation and error prevention |

|
2. Understanding Serial Numbers in Barcode Labels |
2.1 What Are Serial Numbers |
Serial numbers uniquely identify each product unit. They are essential for: |
1. Quality control |
2. Warranty tracking |
3. Anti-counterfeiting |
4. Regulatory compliance |
2.2 Serial Number Formats |
Serial numbers can be: |
1. Numeric (e.g., 000001, 000002 |
2. Alphanumeric (e.g., A001B, A002B |
3. Date-coded (e.g., YYMMDD001) |
2.3 Excel Implementation |
* Use auto-fill or formulas to generate sequences |
* Include prefix/suffix for product or batch identification |
Example numeric sequence formula in cell `A2`: |
```id='sn1' |
=TEXT(ROW()-1,'000001') |
``` |
This will generate `000001` in row 2, `000002` in row 3, etc. |

|
3. Batch Codes for Production Tracking |
3.1 Purpose of Batch Codes |
Batch codes track: |
1. Manufacturing lot |
2. Production date |
3. Expiration date |
4. Supplier or plant location |
3.2 Format Examples |
1. `B20260406` Batch produced on April 6, 2026 |
2. `PL01-04-26` Plant 01, April 26 |
3. Alphanumeric combinations for unique identification |
3.3 Excel Formula for Batch Codes |
If `A2` contains production date: |
```id='sn2' |
='B' & TEXT(A2,'YYYYMMDD') |
``` |
This generates `B20260406` for April 6, 2026. |

|
4. Integrating Serial Numbers and Batch Codes in Barcodes |
4.1 Combining Fields |
1. Concatenate product code + serial number + batch code |
2. Apply barcode font or generate ZPL |
Example in Excel: |
```id='sn3' |
=A2 & '-' & B2 & '-' & C2 |
``` |
Where: |
* `A2` = Product code |
* `B2` = Serial number |
* `C2` = Batch code |
4.2 Encoding in 1D or 2D Barcode |
1. 1D (Code 128, Code 39) good for alphanumeric codes |
2. 2D (QR Code, DataMatrix) preferred for long combined codes |

|
5. Variable Data Printing (VDP) Basics |
5.1 Definition |
VDP refers to printing labels where each item has unique data, including: |
1. Serial numbers |
2. Batch numbers |
3. Expiration dates |
4. QR Codes linking to product information |
5.2 Advantages |
1. Automates mass label creation |
2. Ensures traceability |
3. Supports compliance with FDA, ISO, GS1 |

|
6. Implementing VDP in Excel |
6.1 Step 1: Prepare Your Data Table |
Columns may include: |
1. Product Code |
2. Serial Number |
3. Batch Code |
4. Expiration Date |
5. Barcode String (concatenated data) |
6.2 Step 2: Generate Barcode Strings |
Formula example for Code 128: |
```id='sn4' |
='*' & A2 & B2 & C2 & '*' |
``` |
For QR Codes, generate a URL or data string: |
```id='sn5' |
='https://example.com/productcode=' & A2 & '&serial=' & B2 & '&batch=' & C2 |
``` |
6.3 Step 3: Apply Barcode Fonts or Images |
* Apply Code 128 font for linear barcodes |
* Generate QR Code image using API or add-in |
6.4 Step 4: Format Label Template |
Include: |
1. Product name |
2. Barcode |
3. Serial number |
4. Batch code |
5. Expiration date |

|
7. Traceability Labels for Pharmaceuticals |
7.1 Regulatory Requirements |
Pharmaceuticals require: |
1. Unique Identifier (UI) combination of GTIN, serial number, batch code, expiration date |
2. Compliance with GS1 DataMatrix |
3. Readable by regulators and supply chain partners |
7.2 Excel Implementation |
1. Create columns: GTIN, Serial, Batch, Expiration |
2. Concatenate for DataMatrix string |
3. Generate DataMatrix image using API or add-in |
Example concatenation: |
```id='sn6' |
=A2 & B2 & C2 & TEXT(D2,'YYMMDD') |
``` |
Where `D2` = expiration date |

|
8. Traceability in Food and Beverage Industry |
* Batch codes track production for recalls |
* Serial numbers help prevent counterfeit goods |
* QR Codes can link to nutrition, origin, and production data |

|
9. Integrating Variable Data with ZPL for Printing |
9.1 ZPL Example with Serial and Batch |
```id='sn7' |
^XA |
^FO50,50^A0N,30,30^FDProduct: ^FS |
^FO50,90^A0N,25,25^FDSerial: 12345^FS |
^FO50,130^A0N,25,25^FDBatch: B20260406^FS |
^FO50,170^BCN,100,Y,N,N |
^FD12345^FS |
^XZ |
``` |
9.2 Automation Using Excel |
1. Use formulas to generate ZPL code for each row |
2. Export as `.txt` |
3. Send batch to printer |

|
10. Large-Scale VDP Strategies |
10.1 Challenges |
1. Printer buffer limits |
2. Large datasets in Excel |
3. API or add-in rate limits |
10.2 Optimization Techniques |
1. Split data into batches |
2. Reduce image size for QR Codes if acceptable |
3. Use network printing efficiently |

|
11. Data Validation and Error Prevention in VDP |
11.1 Duplicate Serial Numbers |
* Conditional formatting or formulas to flag duplicates |
* Prevents compliance violations |
11.2 Check Expiration Dates |
* Use Excel formulas to highlight expired or invalid dates |
Example: |
```id='sn8' |
=IF(D2 |
``` |
11.3 Validate Barcode Length |
* Ensure barcodes meet standards |
* Example: Code 128 can encode up to 48 characters without extension; longer strings may require 2D barcode |

|
12. Combining 1D and 2D Barcodes |
* 1D: Code 128 for serial or SKU |
* 2D: QR or DataMatrix for traceability info |
* Example: Packaging may have a Code 128 barcode for retail scanning and a QR Code linking to batch details |

|
13. Adding Expiration Dates |
13.1 Excel Formulas for Date Strings |
* `TEXT(D2,'YYMMDD')` `260406` for April 6, 2026 |
* Combine with serial or batch: `=B2 & '-' & TEXT(D2,'YYMMDD')` |
13.2 Including in Barcode |
* Append to linear or 2D barcode string |
* Ensure scanner compatibility |

|
14. Serialization Strategies |
1. Sequential numbering for each production unit |
2. Batch reset for each production lot |
3. Prefix or suffix for plant or product identification |

|
15. Automation for Multi-Product Printing |
15.1 Using VBA |
1. Loop through Excel rows |
2. Generate barcode strings |
3. Export ZPL for each product |
Example pseudo-code: |
```id='sn9' |
For Each Row in DataTable |
GenerateBarcode(Row) |
ExportZPL(Row) |
Next |
``` |

|
16. Printing Traceability Labels |
* Ensure each label is unique |
* Use thermal transfer or direct thermal printer |
* Verify printed codes with handheld scanners |

|
17. Regulatory Compliance Checklists |
For pharmaceutical or food labels: |
1. Unique Identifier (UI) |
2. Batch/Lot number |
3. Serial number |
4. Expiration date |
5. Compliance with GS1 DataMatrix standards |
6. Print legibility and quiet zones |

|
18. Error Handling During VDP |
1. Invalid serial numbers flag in Excel |
2. Missing batch or expiration date halt printing |
3. Barcode generation errors log and retry |

|
19. Advantages of Excel-Based VDP |
1. Centralized control of serial, batch, and expiration data |
2. Ability to automate large-scale label generation |
3. Integration with barcode fonts, QR/2D codes, and ZPL |
4. Compliance with regulatory standards |

|
20. Conclusion of Part 7 |
In this part, we covered variable data printing and traceability: |
1. Generating serial numbers and batch codes in Excel |
2. Integrating dynamic data into 1D and 2D barcodes |
3. Automating VDP workflows with formulas and VBA |
4. Traceability labels for pharmaceuticals, food, and logistics |
5. Error prevention, validation, and compliance strategies |

|
Next Step |
In Part 8, we will explore: |
* Integrating Excel barcode labels with ERP and inventory systems |
* Real-time data updates for dynamic label printing |
* Multi-user collaboration |
* Automation and workflow optimization for enterprise environments |