I was tasked with trying to create a VBA Macro that will generate barcodes based on the values I have and also create a button that will print only the barcodes and not the values. I have found online some options to generate the barcodes but the format does not look correct as I also need the number on the bottom of the barcode. I'm a beginner at using VBA macro and I am not sure whether all of this is entirely possible?
This is a link to the current VBA I use to generate my barcodes:
This is an example of what I would like my barcodes to be:
CodePudding user response:
You could do something like this:
Sub Tester()
Dim c As Range, v As String, bc
For Each c In Range("A1:A5").Cells 'values to create barcodes from
v = c.Value 'value to be barcoded
bc = Code128(v) 'using your linked function
With c.Offset(0, 1)
.Font.Size = 12 'reset font size
.Font.Name = "Calibri" 'reset font
.HorizontalAlignment = xlCenter
.Value = bc & vbLf & v
'format the barcode characters
.Characters(1, Len(bc)).Font.Name = "Libre Barcode 128"
.Characters(1, Len(bc)).Font.Size = 16
End With
Next c
End Sub
Output: