Coverting Alphabets into Numbers
Marcus,
Not sure if this wil prove faster, but avoiding the Mid/Left etc text
function in favour of maths (and 1 concatenation) is an alternative:
Public Function DecodeString(EncodedStr As String) As Long
Dim bytArray() As Byte
Dim i As Long
Dim OutStr As String
Const ASCII_OFFSET As Long = 64
Const MAX_CODE As Long = 10
bytArray = UCase(EncodedStr)
For i = LBound(bytArray) To UBound(bytArray) Step 2
bytArray(i) = bytArray(i) - ASCII_OFFSET
If bytArray(i) = MAX_CODE Then bytArray(i) = 0
OutStr = OutStr & bytArray(i)
Next
DecodeString = CLng(OutStr)
End Function
NickHK
"Marcus" wrote in message
...
I hope someone can help me with this.
I have a column of "encrypted" data (in excel), which needs to be
converted.
The data in each cell is "encrypted" by following this simple rule:
A = 1
B = 2
C = 3
D = 4
E = 5
F = 6
G = 7
H = 8
I = 9
J =0
Therefore, if a cell has "BFDJ", the numerical value will be 2640.
My problem is this:
How can I take the sum of the "encrypted" data in the column to make a
grand
total, which is also encrypted using the above rule?
I've looked around and it seems that there are functions which can change
numbers into words, but not the other way round.
Any assistance is much appreciated.
|