Generate Code 128 Barcode Font For Excel [6 Simple Steps]

It’s the smartest decision you have ever made by clicking on this post.

I know that you are the owner of a small retail business that sells a variety of products, including clothing, accessories, and small electronics.

And as your business grows, you begin to find it difficult to keep track of your inventory and sales data.

No worries, I’ve got you covered.

In this tutorial, I will show you a more efficient system to manage your inventory and streamline your sales process.

Yes, you got it right!

Why waste money buying such stickers when you can make one?

Buckle up, because I will help you use barcodes for each product in your inventory. After that you can use a barcode scanner to quickly scan the code when an item is sold.

Like a pro, this technique will help you make informed business decisions.

So, let’s get started.

excel-barcode-128

What Does Code 128 Do in Excel?

Code 128 is a widely used linear barcode symbology that is used to encode alphanumeric data. This barcode font contains patterns of vertical bars and spaces that represent characters, numbers, and other data. The barcode scanner reads the pattern of bars and spaces and decodes it into the original data.

I widely use this strategy in logistics and shipping industries to encode data, such as product codes, serial numbers, and other identifying information.

Think of it as a “secret code” that unlocks the hidden information stored in a spreadsheet. Just like a secret puzzle, the data is encoded in a way that only those with the right tools and knowledge can decipher it.

Code 128 barcode font consists of seven sections.

barcode-explanation

The seven sections are:

  1. Quiet Zone: A clear area that surrounds the barcode on all four sides. It is used to prevent any interference with the barcode scanning process.
  2. Start Code: It is a special pattern that identifies the start of the barcode. In Code 128, the start code is always “11010000100”.
  3. Data Code: This section contains the actual data that is being encoded in the barcode. It can include alphanumeric characters, symbols, and control codes.
  4. Checksum: A calculated value based on the data code that is used to verify the accuracy of the barcode during scanning.
  5. Stop Code: It is a special pattern that marks the end of the barcode. In Code 128, there are three possible stop codes, depending on the version of the barcode being used.
  6. Quiet Zone: Another clear area that follows the barcode on all four sides. It is used to signal the end of the barcode and to prevent any interference with the next barcode that may be scanned.
  7. Optional Human Readable Text: This section displays the encoded data in the human-readable form below or above the barcode. It is optional, but often included to assist with manual data entry or verification.

How To Generate Code 128 Barcode in Excel

There are exactly six steps in this overall procedure.

Here are the steps to generate a barcode in Excel:

1. Download Free Barcode Font 128

First of all you need to download the font. Luckily, the font is free to download. You must download the free barcode 128 font and extract the downloaded folder. Make sure to extract the folder on C:\Windows.

2. Apply the VBA Code

Open an Excel workbook and go to the Developer Tab. Click on Visual basic. Select the Insert Module option and paste the following VBA Code:

Option Explicit
Public Function Code128(SourceString As String)
Dim Counter As Integer
Dim CheckSum As Long
Dim mini As Integer
Dim dummy As Integer
Dim UseTableB As Boolean
Dim Code128_Barcode As String
If Len(SourceString) > 0 Then
For Counter = 1 To Len(SourceString)
Select Case Asc(Mid(SourceString, Counter, 1))
Case 32 To 126, 203
Case Else
MsgBox "Invalid character in barcode string" & vbCrLf & vbCrLf & "Please only use standard ASCII characters", vbCritical
Code128 = ""
Exit Function
End Select
Next
Code128_Barcode = ""
UseTableB = True
Counter = 1
Do While Counter <= Len(SourceString)
If UseTableB Then
mini = IIf(Counter = 1 Or Counter + 3 = Len(SourceString), 4, 6)
GoSub testnum
If mini% < 0 Then
If Counter = 1 Then
Code128_Barcode = Chr(205)
Else
Code128_Barcode = Code128_Barcode & Chr(199)
End If
UseTableB = False
Else
If Counter = 1 Then Code128_Barcode = Chr(204)
End If
End If
If Not UseTableB Then
mini% = 2
GoSub testnum
If mini% < 0 Then
dummy% = Val(Mid(SourceString, Counter, 2))
dummy% = IIf(dummy% < 95, dummy% + 32, dummy% + 100)
Code128_Barcode = Code128_Barcode & Chr(dummy%)
Counter = Counter + 2
Else
Code128_Barcode = Code128_Barcode & Chr(200)
UseTableB = True
End If
End If
If UseTableB Then
Code128_Barcode = Code128_Barcode & Mid(SourceString, Counter, 1)
Counter = Counter + 1
End If
Loop
For Counter = 1 To Len(Code128_Barcode)
dummy% = Asc(Mid(Code128_Barcode, Counter, 1))
dummy% = IIf(dummy% < 127, dummy% - 32, dummy% - 100)
If Counter = 1 Then CheckSum& = dummy%
CheckSum& = (CheckSum& + (Counter - 1) * dummy%) Mod 103
Next
CheckSum& = IIf(CheckSum& < 95, CheckSum& + 32, CheckSum& + 100)
Code128_Barcode = Code128_Barcode & Chr(CheckSum&) & Chr$(206)
End If
Code128 = Code128_Barcode
Exit Function
testnum:
mini% = mini% - 1
If Counter + mini% <= Len(SourceString) Then
Do While mini% >= 0
If Asc(Mid(SourceString, Counter + mini%, 1)) < 48 Or Asc(Mid(SourceString, Counter + mini%, 1)) > 57 Then Exit Do
mini% = mini% - 1
Loop
End If
Return
End Function

Explanation of the Code

The VBA code I inserted is used to create a Code 128 barcode from a given string of text. The Code128 function takes in a string parameter, and the code consists of a series of variables, loops, and decision structures used to convert the string to a barcode.

The code consists of several segments and it starts by defining variables for the counter, checksum, minimum value, and a flag for using Table B. It then checks that the string contains only standard ASCII characters and displays an error message if it contains any other characters.

After that you are commanding Excel to create the barcode by iterating through each character in the string and determining whether to use Table A or Table B to encode the character. It then adds the encoded character to the barcode string.

After the barcode has been created, the code calculates the checksum value, appends it to the barcode, and returns the barcode string.

Overall, this code is a function that can be called from other VBA modules or Excel worksheets to generate Code 128 barcodes.

3. Use the Code 128 Function Created Using VBA

First, enable iteration to avoid circular references error. Go to File>Options>Formulas>Enable Iteration.

enable-iteration-excel

Select an empty cell and use the Code128 function. Type =CODE128(cell reference) and press Enter. The function will convert the data into a unique barcode. Now, you need to decipher the code and transform it into arrays of lines.

add-barcode-excel

4. Change The Font Style & Size

Go to the Home Tab. Select Code 128 as the Font Style. If you cannot see the font style, check the C:\Windows\Fonts folder. Install the Code 128 font (if needed).

code-128-regular-font-install

Select the size of the text as 36. This will allow the unique code to transform into a barcode.

bar-code-128-excel

5. Resize The Cell Height and Width

Resize the cell’s height and width according to your preference. Print the excel sheet and start creating stickers and tag the labels onto your products. Use the scanner to scan the information of the barcode quickly.

ascii-codes-excel

6. Use The Fill Handle

A surprising feature of Excel is the Fill Handle. You can use this feature to copy the formula up to your preferred range of cells so that you don’t have to go through all the five processes step-by-step all over again.

FAQ

Is there a barcode font for Excel?

By Default, there aren’t any bar code fonts in Excel. You have to download the font from authentic sources. Note that not all downloadable fonts will work on Excel.

Final Words

Now you can tag codes to your products or get a decent job by making barcodes for a company. Both sides, you will get dollars of cash running in your bank account.

Just follow the six processes mentioned in this content, and you are good to go.