Function Azalea_ITF_14(ByVal ITF_14 As String) As String ' I2of5Tools 25mar09 jwhiting ' Copyright 2009 Azalea Software, Inc. All rights reserved. www.azaleabarcodes.com ' Creating an ITF-14 barcode in Excel ' Your input, ITF_14, is a 13-digit numeric string to be encoded as an ITF-14 symbol. Dim temp As String ' a temporary placeholder Dim temp2 As String ' a temporary placeholder Dim chunk As String ' loop chunk Dim checkDigitSubtotal As Integer ' the check digit subtotal Dim checkDigit As String ' do the check digit calculation over all 13 digits checkDigitSubtotal = 3 * (Val(Mid(ITF_14, 1, 1)) + Val(Mid(ITF_14, 3, 1)) + Val(Mid(ITF_14, 5, 1)) + Val(Mid(ITF_14, 7, 1)) + Val(Mid(ITF_14, 9, 1)) + Val(Mid(ITF_14, 11, 1)) + Val(Mid(ITF_14, 13, 1))) checkDigitSubtotal = checkDigitSubtotal + Val(Mid(ITF_14, 2, 1)) + Val(Mid(ITF_14, 4, 1)) + Val(Mid(ITF_14, 6, 1)) + Val(Mid(ITF_14, 8, 1)) + Val(Mid(ITF_14, 10, 1)) + Val(Mid(ITF_14, 12, 1)) checkDigit = Right(Str(300 - checkDigitSubtotal), 1) ITF_14 = ITF_14 & checkDigit ' now ITF_14 is a 14 (even) digit number temp2 = ITF_14 ' divide input into pairs of digits For i = 1 To Len(ITF_14) / 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_ITF_14 = Chr(171) + temp + Chr(172) ' Excel: B1=Azalea_ITF_14(A1) ' Or put another way, yourContainer.text=Azalea_ITF_14(yourInputString) End Function