' This VBA macro works in Excel; it will not work in ' Google Sheets, OpenOffice, or GNumeric. ' Insert the following into an empty new Excel spreadsheet and ' paste the following two macros. Then run the two that begin with ' the word "Action" Sub Action_CreateCharTable() HexDigits = "0123456789ABCDEF" ' Fill in values from 00 to FF For Column = 1 To 16 For Row = 1 To 16 CellName = Chr(Column + 64) & Row HexValue = "'" & Mid(HexDigits, Row, 1) & Mid(HexDigits, Column, 1) Range(CellName).Value = HexValue Next Next ' Align values in the center of each cell Range("A1:P16").Select With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With Range("A1").Select End Sub Sub Action_SaveFile() ' Collect hexadecimal numbers from cells into a string HexString = "" For Row = 1 To 16 For Column = 1 To 16 CellName = Chr(Column + 64) & Row HexString = HexString & Range(CellName).Value Next Next Call CreateHexFile("ASCII.BIN", HexString) End Sub ' USAGE: Call CreateHexFile(FileName, StringContent) Sub CreateHexFile(FileName, Content) ' Create the file Set FSO = CreateObject("Scripting.FileSystemObject") Set F = FSO.CreateTextFile(FileName, 1, 0) If VarType(Content) = vbString Then D = 0 ' Number of hexadecimal digits we have encountered Output = "" ' Binary string output For I = 1 To Len(Content) ' The following line captures digits and uppercase and lowercase letters (A-F) and ' outputs a number between 0 and 16. If it's zero, then that means ' the input character was not a hexadecimal digit. P = InStr("123456789abcdef0123456789ABCDEF", Mid(Content, I, 1)) If P > 0 Then D = D + 1 P = P And 15 If D And 1 Then ' Store high nibble in U U = P * 16 Else ' Combine high nibble and low nibble U + P Output = Output & Chr(U + P) End If End If Next ' Write last digit if there were an odd number of digits: If D And 1 Then Output = Output & Chr(U) F.Write Output End If F.Close End Sub