Calculating UPC Barcode Check Digits

ktothek

New Member
Joined
Mar 20, 2008
Messages
4
Hello everyone,

I am new at the forum, and have a tricky question.

My company uses UPC codes for identifying its products. As you might know, the UPC codes have 11 digits + 1 digit check code. And the formulation to calculate this check digit is as following:

Step One: From the right to the left, start with odd position, assign the odd/even position to each digit.
calc-upc-diagram1.gif

Step Two: Sum all digits in odd position and multiply the result by 3. (7+6+1+1+5+2)*3=66
Step Three: Sum all digits in even position. (2+4+2+7+4)=19
Step Four: Sum the results of step three and four: 66+19=85
Step Five: Divide the result of step four by 10. The check digit is the number which adds the remainder to 10. In our case, divide 85 by 10 we get the remainder 5. The check digit then is the result of 10-5=5.



So, what I did to calculate this was like that:
1. Cell A1 is the eleven digit number: 72641217542
2. Cells A2 to A12 are 7, 2, 6, 4, 1, 2, 1, 7 ,5, 4, 2 correspondingly.
3. Cell A13 has the following formula to calculate the check digit:

=RIGHT(ROUNDDOWN((10-((((((A12+A10+A8+A6+A4+A2)*3)+(A3+A5+A7+A9+A11))/10)-ROUNDDOWN((((A12+A10+A8+A6+A4+A2)*3)+(A3+A5+A7+A9+A11))/10,0))*10)),0),1)


4. Cell A14 has the following formula to combine whole:

=CONCATENATE(A1,A13)


I know it is complicated but it works perfectly. Could you guys advice me any other shorter ways to do that?

Thanks in advance,

Ray
 
Last edited:

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Welcometo the board!

There must be a better way of getting the Odds/Evens but this is a little shorter:

PHP:
=CONCATENATE(A2,10-MOD(((B2+D2+F2+H2+J2+L2)*3)+(C2+E2+G2+I2+K2),10))

A2 is the 11 digit number and B2:L2 are the individual digits
HTH
CC
 
Upvote 0
Thanks for your answer.

I gave that a try but it calculates some of them but gives wrong numbers for somes. Check that number both manually and with your formula:

84479400005

It should be 6 but your formula calculates 7.

Maybe a slight correction in the formula could correct it.

Thanks again.

Ray
 
Upvote 0
Put the UPC # in A1

Put the following in B1 =CONCATENATE(A1,RIGHT(ROUNDDOWN((SUM(RIGHT(A1,1)+MID(A1,9,1)+MID(A1,7,1)+MID(A1,5,1)+MID(A1,3,1)+LEFT(A1,1))*3+SUM(MID(A1,10,1)+MID(A1,8,1)+MID(A1,6,1)+MID(A1,4,1)+MID(A1,2,1))),1)))

Kurt
 
Upvote 0
I independently came up with the same formula as custardcrumble, being:
=10-MOD(((A12+A10+A8+A6+A4+A2)*3)+(A3+A5+A7+A9+A11),10)

Manually check your maths on 84479400005 - I believe the answer should be 7 per your instructions in your first post.

Andrew
 
Upvote 0
Hmm, I've done it manualy and get 7...
Odds: 8+4+9+0+0+5=26, times 3=78
Evens: 4+7+4+0+0=15
Sum=93
Remainder = 3
10-Remainder=7...

Or have I misinterpreted your description?
CC
 
Upvote 0
Agree with stapuff about using MID to save writing out the digits separately or you could write a simple macro to do it for you. Depends how easy to read you want your formula!

CC :)
 
Upvote 0
the rounddown right 1 of the result automatically gives you the remainder, doesn't it?
 
Upvote 0

Forum statistics

Threads
1,214,635
Messages
6,120,660
Members
448,975
Latest member
sweeberry

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top