Function Azalea_Interleaved_2_of_5(ByVal I2of5 As String) As String ' I2of5Tools 30jan14 jwhiting ' Copyright 2014 Azalea Software, Inc. All rights reserved. www.azaleabarcodes.com ' Creating an Interleaved 2 of 5 barcode in Excel ' Your input, I2of5, is a numeric string to be encoded as an Interleaved 2 of 5 symbol. Dim i As Integer ' our loop counter Dim chunk As String ' loop chunk Dim temp As String ' a temporary placeholder Dim temp2 As String ' a temporary placeholder ' Interleaved 2 of 5 represents pairs of numbers. ' If the input is an odd number of digits long, it is padded with a leading zero. If Len(I2of5) Mod 2 <> 0 Then ' if the input has odd number of digits I2of5 = "0" + I2of5 ' pad it with a leading zero End If temp2 = I2of5 ' divide input into pairs of digits For i = 1 To Len(I2of5) / 2 chunk = Left(temp2, 2) ' grab 2 characters If Val(chunk) < 90 Then ' offset into fonts' character set temp = temp + Chr(Val(chunk) + 33) ElseIf Val(chunk) = 90 Then temp = temp + Chr(182) ElseIf Val(chunk) = 91 Then temp = temp + Chr(183) ElseIf Val(chunk) > 91 Then temp = temp + Chr(Val(chunk) + 104) End If temp2 = Right(temp2, Len(temp2) - 2) ' move to the next two characters Next i ' Add the start and stop bars (ASCII 171 & ASCII 172). Azalea_Interleaved_2_of_5 = Chr(171) + temp + Chr(172) ' yourBarcode = Azalea_Interleaved_2_of_5(yourInputString) End Function