Design and Print Barcode Labels Using Excel |
Part 13: Advanced Excel Formulas, Conditional Formatting, and Dynamic Label Customization |
1. Introduction |
In Part 12, we explored VBA automation, multi-page printing, and error handling. While VBA automates barcode generation and placement, Excel formulas and conditional formatting allow dynamic, real-time adjustments to barcode data and label design. This part covers: |
1. Advanced Excel formulas for barcode data |
2. Dynamic concatenation of multiple fields |
3. Conditional formatting for alerts and highlights |
4. Label customization based on batch, expiry, or category |
5. Optimization for industrial and retail use |

|
2. Advanced Concatenation Techniques |
2.1 Concatenating Multiple Fields |
When generating barcodes, multiple product fields are often combined into a single string. Excel offers multiple methods: |
Method 1: Ampersand (`&`) Operator |
```excel |
='(01)' & A2 & '(17)' & TEXT(B2,'YYMMDD') & '(10)' & C2 |
``` |
* `(01)` GTIN |
* `(17)` Expiration date |
* `(10)` Batch number |
Method 2: CONCAT Function (Excel 2016+) |
```excel |
=CONCAT('(01)', A2, '(17)', TEXT(B2,'YYMMDD'), '(10)', C2) |
``` |
Method 3: TEXTJOIN Function |
* Useful when separating multiple optional fields with delimiters |
```excel |
=TEXTJOIN('|', TRUE, A2, TEXT(B2,'YYMMDD'), C2, D2) |
``` |
* `'|'` acts as a delimiter |
* `TRUE` ignores empty cells |
2.2 Conditional Concatenation |
Sometimes a field may be optional (e.g., batch number or serial). Conditional concatenation avoids adding empty placeholders: |
```excel |
='(01)' & A2 & '(17)' & TEXT(B2,'YYMMDD') & IF(C2<>'','(10)' & C2,'') |
``` |
* Only adds batch `(10)` if C2 is not empty |
* Prevents invalid barcode formats |

|
3. Handling Check Digits |
Many barcodes require check digits for validation. Excel can calculate them using formulas. |
3.1 EAN-13 Check Digit Formula |
```excel |
=MOD(10-MOD(SUMPRODUCT(MID(A2,ROW(INDIRECT('1:12')),1)*{1,3,1,3,1,3,1,3,1,3,1,3}),10),10) |
``` |
* Ensures numeric GTIN is valid |
* Can append to barcode string dynamically: |
```excel |
='(01)' & A2 & EANCheckDigit & '(17)' & TEXT(B2,'YYMMDD') |
``` |
3.2 Modulo-43 Check for Code 39 |
* Code 39 uses modulo-43 check digits |
* Excel formula calculates ASCII values, sums, and returns corresponding character |
```excel |
=CHAR(MOD(SUMPRODUCT(CODE(MID(A2,ROW(INDIRECT('1:' & LEN(A2))),1))),43)+48) |
``` |
* Integrates directly into barcode string formula |

|
4. Conditional Formatting for Alerts |
Conditional formatting highlights important label elements such as expiring products, missing data, or priority items. |
4.1 Highlight Expired or Near-Expiry Items |
* Select column with expiration dates |
* Conditional Formatting New Rule Use Formula: |
```excel |
=B2<=TODAY()+30 |
``` |
* Highlights products expiring within 30 days |
* Choose fill color (e.g., red or orange) |
4.2 Highlight Missing Fields |
* Example: highlight rows with missing GTIN, Batch, or Expiration |
```excel |
=OR(A2='', B2='', C2='') |
``` |
* Immediately flags incomplete entries for review |
4.3 Color-Coding by Category |
* Example: different colors for product types |
```excel |
=$D2='Electronics' |
``` |
* Helps in multi-category labels for warehouses or retail |

|
5. Dynamic Label Customization |
5.1 Multiple Fields in One Label |
* Display GTIN, batch, expiry, and product name together |
* Use Excel alignment, wrap text, and merge cells to adjust visual layout |
Example formula for display: |
```excel |
='Product: '&D2&CHAR(10)&'GTIN: '&A2&CHAR(10)&'Batch: '&C2&CHAR(10)&'Exp: '&TEXT(B2,'YYMMDD') |
``` |
* `CHAR(10)` adds line breaks |
* Combine with barcode font for readable scanning |
5.2 Adding Dynamic QR Codes |
* Generate URLs or text dynamically: |
```excel |
='https://example.com/productgtin=' & A2 & '&batch=' & C2 & '&exp=' & TEXT(B2,'YYMMDD') |
``` |
* Can be passed to a QR code generator or VBA routine to create label images |
* Each row generates unique QR Code automatically |
5.3 Conditional Text or Label Variations |
* Example: adding ragileor perishable dynamically: |
```excel |
=IF(E2='Perishable','Handle With Care','') |
``` |
* Can be printed alongside barcode for warehouse handling instructions |

|
6. Multi-Line Barcode Text and Human-Readable Info |
* Barcode often needs human-readable text below |
* Combine Excel text and barcode font: |
```excel |
='*' & A2 & '*' & CHAR(10) & 'GTIN: '&A2 & ' Batch: '&C2 |
``` |
* Use `*` for Code 39 start/stop characters |
* Ensure barcode scanner reads only the symbol, not human-readable text |

|
7. Dynamic Page Layout for Labels |
* Excel formulas determine label placement dynamically based on rows and columns |
```excel |
RowPosition = MOD(ROW()-2, RowsPerPage) + 1 |
ColumnPosition = INT((ROW()-2)/RowsPerPage) + 1 |
``` |
* Helps populate multi-label sheets automatically |
* Works with VBA macros to generate print-ready sheets |

|
8. Automation of Data Validation |
8.1 Validate GTIN Format |
```excel |
=IF(LEN(A2)=14,'Valid','Invalid') |
``` |
* Ensures proper length before printing |
8.2 Validate Batch Numbers |
```excel |
=IF(ISNUMBER(C2),'Valid','Check Batch') |
``` |
* Alerts operators to data entry errors |
8.3 Expiry Validation |
```excel |
=IF(B2>=TODAY(),'OK','Expired') |
``` |
* Reduces errors in warehouse or shipping processes |

|
9. Combining Formulas with VBA |
* Excel formulas create dynamic barcode strings |
* VBA reads these formulas and places barcode font or images in label template |
* Formula-driven approach allows real-time updates when data changes |
10. Conditional Formatting in Multi-Page Labels |
* Each page may require color coding for categories, priority, or warnings |
* Conditional formatting ensures visual consistency across all pages |
* Reduces human errors in label selection or batch handling |

|
11. Optimizing Excel for Large Datasets |
* Use structured tables for dynamic range reference |
* Reduce file size by limiting embedded images |
* Combine with VBA to batch-generate barcodes for thousands of rows |
* Conditional formatting applies rules automatically to new rows |
12. Barcode Scaling and Alignment |
* Use formula-generated text with barcode fonts |
* Adjust cell height and width for consistent scanning |
* Ensure sufficient quiet zones around barcode symbols |
* Dynamically resize based on field length |

|
13. Multiple Label Variants in One Workbook |
* Separate sheets for different label types or sizes |
* Excel formulas adjust concatenation for each variant |
* Conditional formatting differentiates product categories |
14. Integration with ERP Data |
* Import ERP-exported product, batch, and expiry data |
* Use Excel formulas to format strings for barcode fonts or 2D images |
* Automate scanning compliance before printing |

|
15. Generating Custom Text for Labels |
* Include special instructions, handling notes, or batch info dynamically: |
```excel |
='SKU: '&A2&' | Exp: '&TEXT(B2,'YYMMDD')&' | Note: '&IF(E2='Fragile','Handle Carefully','') |
``` |
* Automatically adapts to product type and warehouse rules |
16. Combining 1D and 2D Barcode Formulas |
* Example: Code 128 (1D) for retail SKU |
* DataMatrix (2D) for regulatory compliance |
```excel |
1D String: ='*' & A2 & '*' |
2D String: ='(01)' & A2 & '(17)' & TEXT(B2,'YYMMDD') & '(10)' & C2 |
``` |
* Ensures both retail scanning and traceability |

|
17. Real-Time Updates and Dynamic Templates |
* Formula-driven labels update immediately when data changes |
* Supports dynamic stock levels, batch changes, or new product codes |
* Reduces printing errors and waste |
18. Multi-Field Conditional Formatting |
* Highlight expiring items in red |
* Highlight high-priority SKUs in yellow |
* Use formulas for multiple conditions in one sheet: |
```excel |
=AND(B2<=TODAY()+30, D2='Perishable') |
``` |
* Ensures operators take proper action |

|
19. Printing Preview and Formula Verification |
* Always preview printed output |
* Ensure formulas generate correct strings for barcode fonts |
* Test human-readable text and barcode alignment before mass production |
20. Conclusion of Part 13 |
This part emphasized advanced Excel formula usage and dynamic label customization: |
1. Concatenation techniques for multiple barcode fields |
2. Conditional concatenation for optional fields |
3. Check digit calculation for EAN and Code 39 |
4. Conditional formatting for expiry, missing data, and category highlighting |
5. Dynamic QR Code generation |
6. Multi-line, human-readable information integration |
7. Optimization for multi-page, large-scale label production |
8. Integration with ERP and real-time updates |

|
Next Step |
In Part 14, we will focus on: |
* Designing professional label templates in Excel |
* Integrating barcode fonts, images, and logos |
* Optimizing for scanner compatibility, print quality, and industrial-grade labels |