=IF(LEN(L2)=13,EXACT(--RIGHT(ABS((MOD((((MID(L2,1,1)+MID(L2,3,1)+MID(L2,5,1)+MID(L2,8,1)+MID(L2,10,1)+MID(L2,12,1))*3)+(MID(L2,2,1)+MID(L2,4,1)+MID(L2,6,1)+MID(L2,9,1)+MID(L2,11,1))),10)-10)),1),RIGHT(L2,1))
,IF(LEN(L2)=17,EXACT(--RIGHT(ABS((MOD((((MID(L2,1,1)+MID(L2,4,1)+MID(L2,7,1)+MID(L2,9,1)+MID(L2,12,1)+MID(L2,14,1)+MID(L2,16,1))*3)+(MID(L2,3,1)+MID(L2,6,1)+MID(L2,8,1)+MID(L2,10,1)+MID(L2,13,1)+MID(L2,15,1))),10)-10)),1),RIGHT(L2,1))
,IF(LEN(L2)=15,EXACT(--RIGHT(ABS((MOD((((MID(L2,3,1)+MID(L2,5,1)+MID(L2,7,1)+MID(L2,10,1)+MID(L2,12,1)+MID(L2,14,1))*3)+(MID(L2,1,1)+MID(L2,4,1)+MID(L2,6,1)+MID(L2,8,1)+MID(L2,11,1)+MID(L2,13,1))),10)-10)),1),RIGHT(L2,1))
,IF(LEN(L2)=9,EXACT((ROUNDUP(((MID(L2,1,1)+MID(L2,3,1)+MID(L2,6,1)+MID(L2,8,1))*3)+(MID(L2,2,1)+MID(L2,4,1)+MID(L2,7,1)),-1))-(((MID(L2,1,1)+MID(L2,3,1)+MID(L2,6,1)+MID(L2,8,1))*3)+(MID(L2,2,1)+MID(L2,4,1)+MID(L2,7,1))),RIGHT(L2,1))
,(LEN(L2)<4)))))
I have that cell change to red if the check digits don't match, but i would prefer to have the cell with the upc change the fill to red if it is typed incorrectly but i don't know how to write the formula in vba. I'd want the macro to run whenever the cell contents are changed. any help would be much appreciated, i'm pretty new to VBA and I just can't figure this one out
Bookmarks