Hi everyone, I'm looking for a little help to create VBA code that computes a check digit for a column of alpha numeric strings (a lockbox scanline for a mailing) in an excel spreadsheet. I created a calculator in excel to compute check digits given variable assumptions, but it only works one scanline at a time and I need something that's scalable to create many check digits for an array of scanlines (VBA). I found a few pieces of code and formulas for numerical only scanlines, but nothing that can handle alphanumeric. Others have posted similar requests but they get a bit wishy washy on documenting the logic making it hard for people to help, so I'm hopeful that's where I differ.
Here are the specs:
Mod10
137 weight
Scanline length: would love the VBA to be able to handle variable lengths.
Alpha substation table
Here's the logic:
Example Scanline (without the check digit):
013100280UAG210021UAMR000021AL0002000
Scanline minus check digit:
Numerically converted (from alpha substitutions above):
Weights (from spec):
Weighted Value (place multiplied by weight):
Sum of Weighted Values: 0+3+21+1+0+0+2+24 etc = 208
Expected Check Digit (ones position of preceding sum): 8
Scanline with check digit: 013100280UAG210021UAMR000021AL00020008
The VBA need only print the check digit (in this case 8) in the cell to the right of the scanline, and the column to the right of that will be a concatenation of the scanline + check digit and that's what sent to the printer.
The coding is decidedly out of my depth, but I can answer any questions about the spec or the logic. Any help would be appreciated.
Here are the specs:
Mod10
137 weight
Scanline length: would love the VBA to be able to handle variable lengths.
Alpha substation table
Alpha Substitutions | |
A | 1 |
B | 2 |
C | 3 |
D | 4 |
E | 5 |
F | 6 |
G | 7 |
H | 8 |
I | 9 |
J | 1 |
K | 2 |
L | 3 |
M | 4 |
N | 5 |
O | 6 |
P | 7 |
Q | 8 |
R | 9 |
S | 1 |
T | 2 |
U | 3 |
V | 4 |
W | 5 |
X | 6 |
Y | 7 |
Z | 8 |
Here's the logic:
Example Scanline (without the check digit):
013100280UAG210021UAMR000021AL0002000
Scanline minus check digit:
0 | 1 | 3 | 1 | 0 | 0 | 2 | 8 | 0 | U | A | G | 2 | 1 | 0 | 0 | 2 | 1 | U | A | M | R | 0 | 0 | 0 | 0 | 2 | 1 | A | L | 0 | 0 | 0 | 2 | 0 | 0 | 0 |
0 | 1 | 3 | 1 | 0 | 0 | 2 | 8 | 0 | 3 | 1 | 7 | 2 | 1 | 0 | 0 | 2 | 1 | 3 | 1 | 4 | 9 | 0 | 0 | 0 | 0 | 2 | 1 | 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 | 0 |
1 | 3 | 7 | 1 | 3 | 7 | 1 | 3 | 7 | 1 | 3 | 7 | 1 | 3 | 7 | 1 | 3 | 7 | 1 | 3 | 7 | 1 | 3 | 7 | 1 | 3 | 7 | 1 | 3 | 7 | 1 | 3 | 7 | 1 | 3 | 7 | 1 |
0 | 3 | 21 | 1 | 0 | 0 | 2 | 24 | 0 | 3 | 3 | 49 | 2 | 3 | 0 | 0 | 6 | 7 | 3 | 3 | 28 | 9 | 0 | 0 | 0 | 0 | 14 | 1 | 3 | 21 | 0 | 0 | 0 | 2 | 0 | 0 | 0 |
Sum of Weighted Values: 0+3+21+1+0+0+2+24 etc = 208
Expected Check Digit (ones position of preceding sum): 8
Scanline with check digit: 013100280UAG210021UAMR000021AL00020008
The VBA need only print the check digit (in this case 8) in the cell to the right of the scanline, and the column to the right of that will be a concatenation of the scanline + check digit and that's what sent to the printer.
The coding is decidedly out of my depth, but I can answer any questions about the spec or the logic. Any help would be appreciated.