Hi all,
I am creating a Function but i just can't get it to work.
In cell A1 i have the following: 871040012345)
In cell A2 i have the formula: =EAN(A1)
As a result i get the errormessage #VALUE
This is the code that comes with the EAN function:
Does anybody know what is wrong here?
Thanks!!
I am creating a Function but i just can't get it to work.
In cell A1 i have the following: 871040012345)
In cell A2 i have the formula: =EAN(A1)
As a result i get the errormessage #VALUE
This is the code that comes with the EAN function:
Code:
Function EAN(EAN12 As String)
Dim Pos1, Pos2, Pos3, Pos4, Pos5, Pos6, Pos7, Pos8, Pos9, Pos10, Pos11, Pos12 As Integer
Dim Total1, Total3 As Integer
Dim InputEAN, EANcheck As String
InputEAN = Right(EAN12, 13)
EANcheck = Right(InputEAN, 1)
If EANcheck = ")" Then
'Define position numbers
Pos1 = Mid(InputEAN, 1, 1)
Pos2 = Mid(InputEAN, 2, 1)
Pos3 = Mid(InputEAN, 3, 1)
Pos4 = Mid(InputEAN, 4, 1)
Pos5 = Mid(InputEAN, 5, 1)
Pos6 = Mid(InputEAN, 6, 1)
Pos7 = Mid(InputEAN, 7, 1)
Pos8 = Mid(InputEAN, 8, 1)
Pos9 = Mid(InputEAN, 9, 1)
Pos10 = Mid(InputEAN, 10, 1)
Pos11 = Mid(InputEAN, 11, 1)
Pos12 = Mid(InputEAN, 12, 1)
'Define totals
Total1 = Pos1 + Pos3 + Pos5 + Pos7 + Pos9 + Pos11
Total3 = (Pos2 + Pos4 + Pos6 + Pos8 + Pos10 + Pos12) * 3
EAN = Total1 & Total3
Else: EAN = "-"
End If
End Function
Does anybody know what is wrong here?
Thanks!!