Tutorial: Using Barcode Fonts in Excel Spreadsheets

If you are creating non-trival barcode types such as Code128 and UPC-A, you can not just type your number and format with a barcode font. This never works. You need to call the macro functions we provided - and format the results with the font instead. It is easy to create and print barcodes in Excel spreadsheets, once you finish this tutorial.

Macro Security Settings

Started with Office 2003, you need to change macro settings in order to run macro. Follow the steps below:

  1. In Excel 2003, choose Tools → Macro → Security.
  2. Set the security to Medium. (See illustation A)
  3. If you are using Excel 2007 or 2010, click on Developer tab, the Macor Security button on the ribbon. Choose "Disable all macros with notification". (See illustation B)
  4. In Excel 2007 and 2010, by default the "developer" tab is not enabled. Follow instructions in Enable Developer Tab in Office 2007/2010 to enable the tab first.

macro security settings macro security settings

Import VBA Macro to Excel

  1. In Excel 2003, choose Tools → Macro → Visual Basic Editor to start Visual Basic Editor.
  2. In Excel 2007/2010, switch to "developer" tab and click on "Visual Basic" on the ribbon.
  3. In Visual Basic Editor, select File → Import File.
  4. Navigate to the folder c:\program files\common files\morovia\moroviafonttools, and select file MoroviaFontTools.bas.

import VBA module to Excel

Creating a Barcode in Excel

  1. Suppose that you want to create code 39 barcode for cell A1.
  2. In the cell that holds the barcode, enter formula =Code39(A1).
  3. Text string *123457* should appear once you hit Enter.
  4. Format the barcode result cell with appropriate code 39 font, such as MRV Code39SA.
  5. If you are creating a different type of barcode, such as Code 128 or UPC-A, you should use a different formula and font. See KB10011: Morovia Font Tools Overview for the exact formula to use.
  6. You can use copy/paste function provided by Excel to copy the formula to other cells. Excel automatically adjust the source cell names. For example, if you copy and paste the barcode cell B1 to B2, Excel will use A2 as the source cell.

barcode formula in excel