Last active
December 26, 2015 00:29
-
-
Save wmakeev/7064858 to your computer and use it in GitHub Desktop.
EAN13 Excel (first 4 digit)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function EAN_13(Code As String) As String | |
Dim s As String | |
s = Code | |
cs = 0 | |
For i = 1 To 12 | |
digit = Mid(s, i, 1) - "0" | |
If i Mod 2 = 0 Then | |
cs = cs + digit * 3 | |
Else | |
cs = cs + digit * 1 | |
End If | |
Next i | |
cs = (10 - (cs Mod 10)) Mod 10 | |
EAN_13 = s & cs | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment