Method 1 – Using Add-in to Create Barcode Without Font
Steps:
- Download an Add-in and install it on your computer.
- Click on the Add-ins ribbon from the Ribbon Bar.
- Click on the barcode panel.
- Select a cell where you want to insert a barcode.
- Select the barcode type from the Barcode drop-down box and type the value in the Data box. I typed ‘ExcelDemy’.
- From the Size section, set the barcode height and width.
- Click Insert Barcode.
The barcode will be inserted.
Read More: How to Create Barcode in Excel
Method 2 – Using Excel VBA to Create Barcode Without Font
Steps:
- Open a new sheet.
- Click as follows to insert a new module: Insert > Module.
- Add the following code in the module-
Sub BarCode128_Generate(ByVal X As Single, ByVal Y As Single, ByVal miHeight As Single, ByVal miLineWeight As Single, _
ByRef miTargetSheet As Worksheet, ByVal miContent As String, Optional miMaxWidth As Single = 0)
Dim miWeightSum As Single
Const miXmmTopt As Single = 0.351
Const miYmmTopt As Single = 0.351
Const miXCompRatio As Single = 0.9
Const miTbar_Symbol As String * 2 = "11"
Dim miCurBar As Integer
Dim i, j, k, miCharIndex, miSymbolIndex As Integer
Dim mitstr2 As String * 2
Dim mitstr1 As String * 1
Dim miContentString As String
Const miAsw As String * 1 = "A"
Const miDsw As String * 1 = "D"
Const miArrdim As Byte = 30
Dim miSw, PrevmiSw As String * 1
Dim miBlockIndex, miBlockCount, miDBlockMod2, miDmiBlockLen As Byte
Dim miBlockLen(miArrdim) As Byte
Dim BlockmiSw(miArrdim) As String * 1
Dim miSymbolValue(0 To 106) As Integer
Dim miSymbolString(0 To 106) As String * 11
Dim miSymbolCharB(0 To 106) As String * 1
Dim miSymbolCharC(0 To 106) As String * 2
For i = 0 To 106
miSymbolValue(i) = i
Next i
For i = 0 To 94
miSymbolCharB(i) = Chr(i + 32)
Next i
miSymbolCharC(0) = "00"
miSymbolCharC(1) = "01"
miSymbolCharC(2) = "02"
miSymbolCharC(3) = "03"
miSymbolCharC(4) = "04"
miSymbolCharC(5) = "05"
miSymbolCharC(6) = "06"
miSymbolCharC(7) = "07"
miSymbolCharC(8) = "08"
miSymbolCharC(9) = "09"
For i = 10 To 99
miSymbolCharC(i) = CStr(i)
Next i
miSymbolString(0) = "11011001100"
miSymbolString(1) = "11001101100"
miSymbolString(2) = "11001100110"
miSymbolString(3) = "10010011000"
miSymbolString(4) = "10010001100"
miSymbolString(5) = "10001001100"
miSymbolString(6) = "10011001000"
miSymbolString(7) = "10011000100"
miSymbolString(8) = "10001100100"
miSymbolString(9) = "11001001000"
miSymbolString(10) = "11001000100"
miSymbolString(11) = "11000100100"
miSymbolString(12) = "10110011100"
miSymbolString(13) = "10011011100"
miSymbolString(14) = "10011001110"
miSymbolString(15) = "10111001100"
miSymbolString(16) = "10011101100"
miSymbolString(17) = "10011100110"
miSymbolString(18) = "11001110010"
miSymbolString(19) = "11001011100"
miSymbolString(20) = "11001001110"
miSymbolString(21) = "11011100100"
miSymbolString(22) = "11001110100"
miSymbolString(23) = "11101101110"
miSymbolString(24) = "11101001100"
miSymbolString(25) = "11100101100"
miSymbolString(26) = "11100100110"
miSymbolString(27) = "11101100100"
miSymbolString(28) = "11100110100"
miSymbolString(29) = "11100110010"
miSymbolString(30) = "11011011000"
miSymbolString(31) = "11011000110"
miSymbolString(32) = "11000110110"
miSymbolString(33) = "10100011000"
miSymbolString(34) = "10001011000"
miSymbolString(35) = "10001000110"
miSymbolString(36) = "10110001000"
miSymbolString(37) = "10001101000"
miSymbolString(38) = "10001100010"
miSymbolString(39) = "11010001000"
miSymbolString(40) = "11000101000"
miSymbolString(41) = "11000100010"
miSymbolString(42) = "10110111000"
miSymbolString(43) = "10110001110"
miSymbolString(44) = "10001101110"
miSymbolString(45) = "10111011000"
miSymbolString(46) = "10111000110"
miSymbolString(47) = "10001110110"
miSymbolString(48) = "11101110110"
miSymbolString(49) = "11010001110"
miSymbolString(50) = "11000101110"
miSymbolString(51) = "11011101000"
miSymbolString(52) = "11011100010"
miSymbolString(53) = "11011101110"
miSymbolString(54) = "11101011000"
miSymbolString(55) = "11101000110"
miSymbolString(56) = "11100010110"
miSymbolString(57) = "11101101000"
miSymbolString(58) = "11101100010"
miSymbolString(59) = "11100011010"
miSymbolString(60) = "11101111010"
miSymbolString(61) = "11001000010"
miSymbolString(62) = "11110001010"
miSymbolString(63) = "10100110000"
miSymbolString(64) = "10100001100"
miSymbolString(65) = "10010110000"
miSymbolString(66) = "10010000110"
miSymbolString(67) = "10000101100"
miSymbolString(68) = "10000100110"
miSymbolString(69) = "10110010000"
miSymbolString(70) = "10110000100"
miSymbolString(71) = "10011010000"
miSymbolString(72) = "10011000010"
miSymbolString(73) = "10000110100"
miSymbolString(74) = "10000110010"
miSymbolString(75) = "11000010010"
miSymbolString(76) = "11001010000"
miSymbolString(77) = "11110111010"
miSymbolString(78) = "11000010100"
miSymbolString(79) = "10001111010"
miSymbolString(80) = "10100111100"
miSymbolString(81) = "10010111100"
miSymbolString(82) = "10010011110"
miSymbolString(83) = "10111100100"
miSymbolString(84) = "10011110100"
miSymbolString(85) = "10011110010"
miSymbolString(86) = "11110100100"
miSymbolString(87) = "11110010100"
miSymbolString(88) = "11110010010"
miSymbolString(89) = "11011011110"
miSymbolString(90) = "11011110110"
miSymbolString(91) = "11110110110"
miSymbolString(92) = "10101111000"
miSymbolString(93) = "10100011110"
miSymbolString(94) = "10001011110"
miSymbolString(95) = "10111101000"
miSymbolString(96) = "10111100010"
miSymbolString(97) = "11110101000"
miSymbolString(98) = "11110100010"
miSymbolString(99) = "10111011110"
miSymbolString(100) = "10111101110"
miSymbolString(101) = "11101011110"
miSymbolString(102) = "11110101110"
miSymbolString(103) = "11010000100"
miSymbolString(104) = "11010010000"
miSymbolString(105) = "11010011100"
miSymbolString(106) = "11000111010"
X = X / miXmmTopt
Y = Y / miYmmTopt
miHeight = miHeight / miYmmTopt
If IsNumeric(miContent) = True And Len(miContent) Mod 2 = 0 Then
miWeightSum = miSymbolValue(105)
miContentString = miContentString + miSymbolString(105)
i = 0
For j = 1 To Len(miContent) Step 2
mitstr2 = Mid(miContent, j, 2)
i = i + 1
k = 0
Do While mitstr2 <> miSymbolCharC(k)
k = k + 1
Loop
miWeightSum = miWeightSum + i * miSymbolValue(k)
miContentString = miContentString + miSymbolString(k)
Next j
miContentString = miContentString + miSymbolString(miSymbolValue(miWeightSum Mod 103))
miContentString = miContentString + miSymbolString(106)
miContentString = miContentString + miTbar_Symbol
Else
Select Case IsNumeric(Mid(miContent, 1, 1))
Case Is = True
miSw = miDsw
Case Is = False
miSw = miAsw
End Select
miBlockCount = 1
BlockmiSw(miBlockCount) = miSw
miBlockIndex = 1
miBlockLen(miBlockCount) = 1
i = 2
Do While i <= Len(miContent)
Select Case IsNumeric(Mid(miContent, i, 1))
Case Is = True
miSw = miDsw
Case Is = False
miSw = miAsw
End Select
If miSw = BlockmiSw(miBlockCount) Then
miBlockLen(miBlockCount) = miBlockLen(miBlockCount) + 1
Else
miBlockCount = miBlockCount + 1
BlockmiSw(miBlockCount) = miSw
miBlockLen(miBlockCount) = 1
miBlockIndex = miBlockIndex + 1
End If
i = i + 1
Loop
miCharIndex = 1
miSymbolIndex = 0
For miBlockIndex = 1 To miBlockCount
If BlockmiSw(miBlockIndex) = miDsw And miBlockLen(miBlockIndex) >= 4 Then
Select Case miBlockIndex
Case Is = 1
miWeightSum = miSymbolValue(105)
miContentString = miContentString + miSymbolString(105)
Case Else
miSymbolIndex = miSymbolIndex + 1
miWeightSum = miWeightSum + miSymbolIndex * miSymbolValue(99)
miContentString = miContentString + miSymbolString(99)
End Select
PrevmiSw = miDsw
miDBlockMod2 = miBlockLen(miBlockIndex) Mod 2
If miDBlockMod2 <> 0 Then
miDmiBlockLen = miBlockLen(miBlockIndex) - miDBlockMod2
Else
miDmiBlockLen = miBlockLen(miBlockIndex)
End If
For j = 1 To miDmiBlockLen / 2 Step 1
mitstr2 = Mid(miContent, miCharIndex, 2)
miCharIndex = miCharIndex + 2
miSymbolIndex = miSymbolIndex + 1
k = 0
Do While mitstr2 <> miSymbolCharC(k)
k = k + 1
Loop
miWeightSum = miWeightSum + miSymbolIndex * miSymbolValue(k)
miContentString = miContentString + miSymbolString(k)
Next j
If miDBlockMod2 <> 0 Then
PrevmiSw = miAsw
miSymbolIndex = miSymbolIndex + 1
miWeightSum = miWeightSum + miSymbolIndex * miSymbolValue(100)
miContentString = miContentString + miSymbolString(100)
miSymbolIndex = miSymbolIndex + 1
mitstr1 = Mid(miContent, miCharIndex, 1)
k = 0
Do While mitstr1 <> miSymbolCharB(k)
k = k + 1
Loop
miWeightSum = miWeightSum + miSymbolIndex * miSymbolValue(k)
miContentString = miContentString + miSymbolString(k)
miCharIndex = miCharIndex + 1
End If
Else
Select Case miBlockIndex
Case Is = 1
miWeightSum = miSymbolValue(104)
miContentString = miContentString + miSymbolString(104)
Case Else
If PrevmiSw <> miAsw Then
miSymbolIndex = miSymbolIndex + 1
miWeightSum = miWeightSum + miSymbolIndex * miSymbolValue(100)
miContentString = miContentString + miSymbolString(100)
End If
End Select
PrevmiSw = miAsw
For j = miCharIndex To miCharIndex + miBlockLen(miBlockIndex) - 1 Step 1
mitstr1 = Mid(miContent, j, 1)
miSymbolIndex = miSymbolIndex + 1
k = 0
Do While mitstr1 <> miSymbolCharB(k)
k = k + 1
Loop
miWeightSum = miWeightSum + miSymbolIndex * miSymbolValue(k)
miContentString = miContentString + miSymbolString(k)
Next j
miCharIndex = j
End If
Next miBlockIndex
miContentString = miContentString + miSymbolString(miSymbolValue(miWeightSum Mod 103))
miContentString = miContentString + miSymbolString(106)
miContentString = miContentString + miTbar_Symbol
End If
If miMaxWidth > 0 And Len(miContentString) * miLineWeight * miXmmTopt > miMaxWidth Then
miLineWeight = miMaxWidth / (Len(miContentString) * miXmmTopt)
miLineWeight = miLineWeight / miXCompRatio
End If
miCurBar = 0
For i = 1 To Len(miContentString)
Select Case Mid(miContentString, i, 1)
Case 0
miCurBar = miCurBar + 1
Case 1
miCurBar = miCurBar + 1
With miTargetSheet.Shapes.AddLine(X + (miCurBar * miLineWeight) * miXCompRatio, Y, X + (miCurBar * miLineWeight) * miXCompRatio, (Y + miHeight)).Line
.Weight = miLineWeight
.ForeColor.RGB = vbBlack
End With
End Select
Next i
End Sub
The image below shows the first portion of the code.
Code Breakdown
- Declared a sub-procedure BarCode128_Generate with some default variables (you can assume that as the parameter of a function).
- Various types of variables have been declared and types are self-descriptive, as the barcode may require these.
- Set values within these variables using FOR loop and used some loops for that purpose. These values are set considering the ASCI
- You can see the miSymbolString array is full of strings of 1 and 0. Here 1 represents the black in the barcode output.
- IF-ELSE statements and CASE statements were for checking different conditions and assigning values.
- Scroll down and go to the end of the codes.
- Enter the following codes after the previous codes-
Sub Barcode_without_Font()
ThisWorkbook.ActiveSheet.Shapes.SelectAll
Selection.Delete
BarCode128_Generate 0, 5, 15, 1.5, ThisWorkbook.ActiveSheet, "ExcelDemy", 90
BarCode128_Generate 154, 0, 8, 0.8, Worksheets("Template"), Worksheets("Template").Cells(2, 3).Value, 90
End Sub
- In the second code, Enter your value between the inverted comma that I have marked with digit 1. I entered ‘ExcelDemy’. and give the output cell reference between the first brackets as marked with digit-2.
- Press the Run icon to run the codes.
- The Macros dialog box will appear, select the specified macro and press the Run tab.
The barcode will be created in the specified cells.
Read More: How to Use EAN 13 Barcode Generator in Excel
Download Practice Workbook
Related Articles
- How to Generate Barcode Numbers in Excel
- How to Convert Numbers to Barcode in Excel
- How to Generate 2D Barcode in Excel
- How to Create Barcode Using 3 of 9 Font in Excel
- How to Calculate Barcode Check Digit with Excel Formula
- How to Add Barcode Font in Excel
- How to Use Code 39 Barcode Font for Excel
- How to Generate Code 128 Barcode Font for Excel
<< Go Back to Create Barcode in Excel | Barcode in Excel | Learn Excel
Get FREE Advanced Excel Exercises with Solutions!
Thank you sooo much!
Dear Eugen Safta,
You are most welcome.
Regards
Shamima Sultana | ExcelDemy