How to create, update bulk barcodes in Excel VBA script coding in Office Excel document?
This example demonstrates how to update those exist "link-to-cell" barcodes in the workbook by using VBA (Visual Basic for Applications) code.
Preparation
- Install Barcode Excel Addin Developer version. File name is OnBarcode.Barcode.Excel.Addin.2025.Developer.Setup.exe
- Make sure the Excel application supports Macros. Or the barcode add-in will be inactive.
-
Prepare a sample Excel document with list of barcode already generated. You can view the detailed guide here:
How to create bulk/multiple barcodes from Excel Cell datas in Excel document?
Step 1: Open prepared Excel file "EAN-13-Data-Sample-Report.xlsx".
Step 2: Open Excel Developer tool "Microsoft Visual Basic for Applications"
On the Excel Ribbon, click the Developer tab.
Then, click Visual Basic in the Code group to open the "Microsoft Visual Basic for Applications" window
Then, click Visual Basic in the Code group to open the "Microsoft Visual Basic for Applications" window
Step 3: Open file "ThisWorkbook" to add VBA script code
Double-click ThisWorkbook in the Project window to open the code file.
Step 4: Add sample VBA code to update barcodes in Excel
Copy all following VB code to the code file.
- Create a new Application.COMAddIns("OnBarcode.OnBarcodeExcelAddIn") object
- Call method UpdateAllBarcode to update all barcodes in the Excel document
Sub CallVSTOMethod() ' Update contents of those cells in the Number column Sheet1.Range("B4").Value = "1234567890123" Sheet1.Range("B5").Value = "1234567890345" Sheet1.Range("B6").Value = "1234567890567" Sheet1.Range("B7").Value = "1234567890789" ' Get a COMAddIn object that represents the OnBarcode.OnBarcodeExcelAddIn VSTO Add-in. Dim addIn As COMAddIn Dim automationObject As Object Set addIn = Application.COMAddIns("OnBarcode.OnBarcodeExcelAddIn2025") ' Get the Object property of the COMAddIn and call the UpdateAllBarcode method. Set automationObject = addIn.Object automationObject.UpdateAllBarcode End Sub
Step 5: Run the VBA code to update all barcodes in Excel document
Press F5 to run the code.
Then, four cells in the Number column have been updated to new values, and four linked Pictures (in Barcode column) have been refreshed by method UpdateAllBarcode.
Then, four cells in the Number column have been updated to new values, and four linked Pictures (in Barcode column) have been refreshed by method UpdateAllBarcode.
Frequently Asked Questions
What is VBA macros in Excel?
Excel Macros are miniature programs which allow you to perform complex tasks,
such as calculating formulas or creating charts, updating cell values from other data source within Excel.
VBA stands for Visual Basic for Applications. It's a programming language that allows you to automate tasks and add functionality in Excel macros.
Using OnBarcode Excel Barcode Generator Add-in developer edition, you can update all generated barcodes using Excel VBA codes.
VBA stands for Visual Basic for Applications. It's a programming language that allows you to automate tasks and add functionality in Excel macros.
Using OnBarcode Excel Barcode Generator Add-in developer edition, you can update all generated barcodes using Excel VBA codes.
How to turn on Developer Tab in Excel application?
To turn on the Developer tab in Excel application toolbar, follow the steps below:
- Right click anywhere on the Excel toolbar menu, and click "Customize the Ribbon...".
- Under "Customize the Ribbon", on the right side of the "Excel Options" dialog box, choose "Main tabs".
- Check the "Developer" check box.
- Click "OK" button.
- You can find the "Developer" tab in the Excel app toolbar.
How to open Visual Basic Editor to update barcodes in Excel app?
After installed Excel Barcode Generator Add-in, you can update all barcode images in Excel document through Macro codes in Visual Basic Editor.
To open the Visual Basic Editor in Excel app, go to the "Developer" tab in Excel toolbar, click "Visual Basic" command.
To open the Visual Basic Editor in Excel app, go to the "Developer" tab in Excel toolbar, click "Visual Basic" command.
What can I do with Excel Barcode Add-in in VBA macro codes?
OnBarcode Excel Barcode Generator add-in provides one API method
Here is a simple scenario in VBA macro code:
UpdateAllBarcode.
You can use it to update all generated barcode images in Excel document.
Here is a simple scenario in VBA macro code:
- Update Excel cells' values from database or other data souces.
- Call method
UpdateAllBarcode. The barcode add-in will update all barcodes with modified data encoded in Excel document.
Can I customize the barcode in VBA using Excel Barcode Add-in?
No. You cannot create new barcode and customize existing barcodes using Excel Barcode Generator add-in.
What you can do is to update all barcodes in the Excel file. You can modify the barcode linked cell values and call method
What you can do is to update all barcodes in the Excel file. You can modify the barcode linked cell values and call method
UpdateAllBarcode to update
all barcodes using barcode add-in freeware.
If I modify the Excel cell value in VBA, will the linked barcode be automatically re-printed?
No. The Excel barcode add-in will not automatically update the barcode images, if the linked cell values are changed in VBA code. However you can
call method
UpdateAllBarcode, which will update all barcode images in the Excel file.
Dim addIn As COMAddIn Dim automationObject As Object Set addIn = Application.COMAddIns("OnBarcode.OnBarcodeExcelAddIn2025") Set automationObject = addIn.Object automationObject.UpdateAllBarcode
