Thread
:
EAN-13 checksum
View Single Post
#
5
Posted to microsoft.public.excel.programming
Stefi
external usenet poster
Posts: 2,646
EAN-13 checksum
Yes, but I think that codes are to be handled as text even if they consists
of purely digits. Leading zeros are as important parts of codes as any other
of their characters.
Stefi
€žNigel€ť ezt Ă*rta:
Caution with the formulaic approach in that if the EAN13 code length is less
than 12, which occurs if the leading zeros are not entered or suppressed as
it appears as a numerical value, an error will occur.
--
Regards,
Nigel
"Stefi" wrote in message
...
Or you can use this formula:
=CEILING(((MID(A2,2,1)+MID(A2,4,1)+MID(A2,6,1)+MID (A2,8,1)+MID(A2,10,1)+MID(A2,12,1))*3)+(MID(A2,1,1 )+MID(A2,3,1)+MID(A2,5,1)+MID(A2,7,1)+MID(A2,9,1)+ MID(A2,11,1)),10)-(((MID(A2,2,1)+MID(A2,4,1)+MID(A2,6,1)+MID(A2,8,1) +MID(A2,10,1)+MID(A2,12,1))*3)+(MID(A2,1,1)+MID(A2 ,3,1)+MID(A2,5,1)+MID(A2,7,1)+MID(A2,9,1)+MID(A2,1 1,1)))
Regards,
Stefi
€žNigel€ť ezt Ă*rta:
Place the following into a standard module, you can then get the EAN13
check
digit by entering the following within a worksheet cell the function name
followed by the EAN13 number. I have not added any error checking to
ensure
that the first part of the EAN number is valid. But the country,
manufacturer, product code could be checked as part of the function.
e.g.
=EAN13cd(123456789123)
Function EAN13cd(Base As Variant) As Integer
Z = 0: Odd = True
For x = Len(Base) To 1 Step -1
If Odd Then
Z = Z + Mid(Base, x, 1) * 3
Odd = False
Else
Z = Z + Mid(Base, x, 1)
Odd = True
End If
Next
EAN13cd = 10 - Z Mod 10
If EAN13cd = 10 Then EAN13cd = 0
End Function
--
Regards,
Nigel
"Don Quai" wrote in message
...
I want to create a function that will allow me to enter in the first 12
numbers of an EAN-13 barcode and have the function calculate the
checksum
and enter it into the appropriate cell. Any ideas?
Reply With Quote
Stefi
View Public Profile
Find all posts by Stefi