Code 39 barcodes in Excel Azalea_Code_39 Copyright 2009 Azalea Software, Inc. All rights reserved. www.azaleabarcodes.com The macro in this spreadsheet creates Code 39 (Code 3 of 9) 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_Code_39 C39Tools prints Code 39 barcodes. Available for Windows, OS X, Linux/UNIX, et al. Free sample code and free tech support. Buy online and download immediately. www.azaleabarcodes.com/Code-39 Function Azalea_Code_39(ByVal Code39 As String) As String ' C39Tools 24mar09 jwhiting ' Copyright 2009 Azalea Software, Inc. All rights reserved. www.azaleabarcodes.com ' Creating a Code 39 barcode in Excel ' Your input, Code39, is a string to be encoded as a Code 39 symbol. ' yourData must be the Code 39 character set. Input error checking is your responsibility. ' The standard Code 39 character set is: A-Z (upppercase), 0-9, $ % + - . / and the space character. Dim i As Integer ' our loop counter Dim chunk As String ' loop chunk Dim temp As String ' a temporary placeholder ' TrueType doesn't support glyphs in the space slot (ASCII 32) ' We've moved the space character to the underscore ( _ ). ' Therefore "APPLE PIE" is formatted as *APPLE_PIE* ' Here's the search and replace, underscore for space: For i = 1 To Len(Code39) chunk$ = Mid$(Code39, i, 1) If chunk = " " Then temp = temp + "_" Else temp = temp + chunk End If Next i ' Add the start and stop bars, the asterisk, before and after the input string. Azalea_Code_39 = "*" + temp + "*" ' Excel: B1=Azalea_Code_39(A1) ' Or put another way, yourContainer.text=Azalea_Code_39(yourInputString) End Function