Interleaved 2 of 5 barcodes in Excel Azalea_Interleaved_2_of_5 Copyright 2009 Azalea Software, Inc. All rights reserved. www.azalea.com The macro in this spreadsheet creates Interleaved 2 of 5 (ITF) barcodes. Because this spreadsheet is built around a macro, you *must* enable macros for this spreadsheet to work! The .xls file is for Excel 2003 and the .xlsm is for Excel 2007. An alternative is to use a User Defined Function as an .xla (Excel 2003) or .xlam (Excel 2007). Press ALT-F11 to view the macro in the Visual Basic Editor. To add the macro to your own spreadsheet: Tools/Macro/Visual Basic Editor Insert/Module Paste in the macro code Close the Visual Basic Editor When you return to your spreadsheet, a new User Defined function is available: Azalea_Interleaved_2_of_5 I2of5Tools prints Interleaved 2 of 5 barcodes. Available for Windows, OS X, Linux/UNIX, et al. Free sample code and free tech support. Buy online and download immediately. www.azalea.com/Interleaved-2-of-5 Function Azalea_Interleaved_2_of_5(ByVal I2of5 As String) As String ' I2of5Tools 25mar09 jwhiting ' Copyright 2009 Azalea Software, Inc. All rights reserved. www.azalea.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) ' Excel: B1=Azalea_Interleaved_2_of_5(A1) ' Or put another way, yourContainer.text=Azalea_Interleaved_2_of_5(yourInputString) End Function