Skip to content

Instantly share code, notes, and snippets.

@wmakeev
Last active December 26, 2015 00:29
Show Gist options
  • Save wmakeev/7064858 to your computer and use it in GitHub Desktop.
Save wmakeev/7064858 to your computer and use it in GitHub Desktop.
EAN13 Excel (first 4 digit)
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