EAN IN EXCEL

FMIGUEL -  
eriiic Posted messages 24581 Registration date   Status Contributeur Last intervention   -
Hello,

I am a novice and I am trying to convert a series of 13 digits into a barcode in Excel. Despite all the help on this site: http://grandzebu.net/index.php?page=/informatique/codbar/ean13.htm, I am unable to implement the following macro in Excel:

Public Function ean13$(chaine$)
'This function is governed by the GNU Lesser General Public License (GNU LGPL)
'V 1.1.1
'Parameters : a 12 digits length string
'Return : * a string which gives the barcode when displayed with the EAN13.TTF font
' * an empty string if the supplied parameter is no good
Dim i%, checksum%, first%, CodeBarre$, tableA As Boolean
ean13$ = ""
'Check for 12 characters
If Len(chaine$) = 12 Then
'And they are really digits
For i% = 1 To 12
If Asc(Mid$(chaine$, i%, 1)) < 48 Or Asc(Mid$(chaine$, i%, 1)) > 57 Then
i% = 0
Exit For
End If
Next
If i% = 13 Then
'Calculation of the checksum
For i% = 12 To 1 Step -2
checksum% = checksum% + Val(Mid$(chaine$, i%, 1))
Next
checksum% = checksum% * 3
For i% = 11 To 1 Step -2
checksum% = checksum% + Val(Mid$(chaine$, i%, 1))
Next
chaine$ = chaine$ & (10 - checksum% Mod 10) Mod 10
'The first digit is taken just as it is, the second one comes from table A
CodeBarre$ = Left$(chaine$, 1) & Chr$(65 + Val(Mid$(chaine$, 2, 1)))
first% = Val(Left$(chaine$, 1))
For i% = 3 To 7
tableA = False
Select Case i%
Case 3
Select Case first%
Case 0 To 3
tableA = True
End Select
Case 4
Select Case first%
Case 0, 4, 7, 8
tableA = True
End Select
Case 5
Select Case first%
Case 0, 1, 4, 5, 9
tableA = True
End Select
Case 6
Select Case first%
Case 0, 2, 5, 6, 7
tableA = True
End Select
Case 7
Select Case first%
Case 0, 3, 6, 8, 9
tableA = True
End Select
End Select
If tableA Then
CodeBarre$ = CodeBarre$ & Chr$(65 + Val(Mid$(chaine$, i%, 1)))
Else
CodeBarre$ = CodeBarre$ & Chr$(75 + Val(Mid$(chaine$, i%, 1)))
End If
Next
CodeBarre$ = CodeBarre$ & "*" 'Add middle separator
For i% = 8 To 13
CodeBarre$ = CodeBarre$ & Chr$(97 + Val(Mid$(chaine$, i%, 1)))
Next
CodeBarre$ = CodeBarre$ & "+" 'Add end mark
ean13$ = CodeBarre$
End If
End If
End Function

Can you please guide me on how to see this darn barcode appear on my table?

Thank you in advance for your help

Fmiguel
Configuration: Windows XP Internet Explorer 7.0

5 réponses

FMIGUEL
 
Hi!!!
No not at all, I work in retail!!!!!!!!!! At work I can do what I need, but on my personal computer, I can't. So I'm looking for a solution.

At work, we use a feature that I can't use at home.

Do you have a solution??

Fmiguel
1