Others

How to Fix Excel Code 128 Barcodes Not Scanning

Elise WilliamsElise Williams Oct 26, 2026 873 views

Question details

The user needs a way to properly generate Code 128 barcodes in Excel, as applying a standard barcode font creates visual barcodes that cannot be read by scanners.

How to Fix Excel Code 128 Barcodes Not Scanning
Product
Microsoft Excel
Device & OS
not provided
Scenario
Generating automated Code 128 barcodes within an Excel spreadsheet for inventory or tracking purposes.
Observed behavior
The generated Code 128 barcodes visually look correct but fail to scan, whereas barcodes generated from external online tools scan perfectly.
Before you start

Verify that your hardware barcode scanner is properly configured to read Code 128 symbology by testing it on a known working barcode generated from an online tool.

Solution 1Recommended

Use a VBA Macro to Calculate the Code 128 Checksum

Implement a VBA macro to automatically generate the mandatory start, stop, and checksum characters required for Code 128 before applying the barcode font.

Code 128 requires specific mathematical encoding to be readable. A standard font cannot perform these calculations. By using a custom VBA function, you can translate your raw data into a properly encoded string that the barcode font can then render into a scannable image.

1
Open the VBA Editor

Press ALT + F11 on your keyboard to open the Microsoft Visual Basic for Applications window.

2
Insert a New Module

Click 'Insert' from the top menu and select 'Module' to create a blank script window.

3
Add the Encoding Function

Paste a reliable open-source Code 128 VBA encoding script (widely available online) into the module, then save and close the VBA editor.

4
Apply the Custom Formula

In your Excel sheet, type your new custom function (e.g., =Code128(A2)) in the destination cell to encode the data.

5
Format with the Barcode Font

Select the cell containing the newly encoded string and change its font to your installed Code 128 font.

Use a VBA Macro to Calculate the Code 128 Checksum
Macro Security: You must save your workbook as an Excel Macro-Enabled Workbook (.xlsm) and ensure macros are enabled in your Trust Center settings for the function to work.
Free Microsoft Office alternative

Manage Complex Spreadsheets and Macros with WPS Office

If you are dealing with barcode generation limitations or expensive licensing in Microsoft Excel, consider switching to WPS Office. It provides a highly compatible, feature-rich spreadsheet environment that fully supports VBA macros for complex Code 128 checksum calculations at no cost.

  1. 1. Download WPS Office: Visit the official WPS website to download and install the free office suite.
  2. 2. Open Your Spreadsheet: Launch WPS Spreadsheet and open your existing Excel inventory or barcode tracking file.
  3. 3. Enable Macros: Accept the security prompt to enable macros so your custom Code 128 encoding functions run seamlessly.
Seamless compatibility with Microsoft Excel .xlsx and .xlsm formatsNative support for advanced VBA macros required for Code 128 encodingLightweight architecture ensures fast loading of large inventory sheetsCompletely free to download with an intuitive, familiar user interface
QA img-9

Frequently Asked Questions

Why does changing the font to Code 128 work visually but fail to scan?

Code 128 symbology requires a specific start character, a complex mathematical checksum character, and a stop character. Simply changing the font only alters the text's appearance but omits these mandatory machine-readable elements, causing scanners to reject it.

Can I generate a Code 39 barcode just by changing the font?

Yes. Unlike Code 128, Code 39 does not strictly require a complex checksum character. You can typically generate a scannable Code 39 barcode by simply adding asterisks to the beginning and end of your text (e.g., ="*"&A2&"*") and applying a Code 39 font.

Can I calculate the Code 128 checksum using built-in Excel formulas instead of VBA?

While it is technically possible using a very long and complex array of nested formulas (using MID, CODE, and MOD functions), it is difficult to maintain and highly prone to errors. Using a VBA function or an add-in is significantly more reliable.