Create barcodes (Code128) in Excel

Barcodes are often used for scanning inventory items, packaging and bin locations.

Use the following instructions to create Code 128 barcodes in Excel. Code 128 allows you to have full ASCII as well as numeric compression.  This will allow you to have alphanumeric characters in a product code.

 

  • Close Excel first.

  • Install the following program, this will install a Code 128 font and a small COM Object for creating barcodes.
    Use this for 32 bit Excel

Use this for 64 bit Excel

  • Open a new blank Worksheet in Excel.

  • Create a custom user function called  ASPCODE128ENCODE. To do so.

    • From Excel press ALT + F11

    • In the VBA Project add a module (Right click on the VBA Project and then insert a module)

    • In the module place the code below:

Function ASPCODE128ENCODE(barcode As String) As String

Dim c128 As Object

Set c128 = CreateObject("Code128.Code_128")

ASPCODE128ENCODE = c128.Calculate(barcode)

Set c128 = Nothing

End Function

 

  • Save the file as xlsm - a macro enabled workbook

  • Close VBA Window and go back to Excel.

  • Type in a barcode in a cell e.g. TEST-VALUE

  • And in another cell where you want a barcode to show, use the following formula:  =ASPCODE128ENCODE(B1)   where B1 is the cell of the TEST-VALUE

  • Make sure the barcode font  of the calculated cell is selected to ASPCode128  as shown.

 

Now you can print off these barcodes.