本帖最后由 雨雪霏霏 于 2014-4-20 15:49 编辑
在 B2 输入以下公式可以将 A2 的 “978-7-5038-6461-2”在 B2 中转换为“7-5038-6461-3”。
请教各位兄弟姐妹:如何把公式用在 VBA 中,即只要活动单元格是在A2中,我运行一下宏,就自动将 A2 中的内容更改为“7-5038-6461-3”。十分感谢!
=MID(A2,5,12)&IF(11-MOD(MID(SUBSTITUTE(A2,"-",),4,1)*10+MID(SUBSTITUTE(A2,"-",),5,1)*9+MID(SUBSTITUTE(A2,"-",),6,1)*8+MID(SUBSTITUTE(A2,"-",),7,1)*7+MID(SUBSTITUTE(A2,"-",),8,1)*6+MID(SUBSTITUTE(A2,"-",),9,1)*5+MID(SUBSTITUTE(A2,"-",),10,1)*4+MID(SUBSTITUTE(A2,"-",),11,1)*3+MID(SUBSTITUTE(A2,"-",),12,1)*2,11)=10,"X",IF(11-MOD(MID(SUBSTITUTE(A2,"-",),4,1)*10+MID(SUBSTITUTE(A2,"-",),5,1)*9+MID(SUBSTITUTE(A2,"-",),6,1)*8+MID(SUBSTITUTE(A2,"-",),7,1)*7+MID(SUBSTITUTE(A2,"-",),8,1)*6+MID(SUBSTITUTE(A2,"-",),9,1)*5+MID(SUBSTITUTE(A2,"-",),10,1)*4+MID(SUBSTITUTE(A2,"-",),11,1)*3+MID(SUBSTITUTE(A2,"-",),12,1)*2,11)=11,0,11-MOD(MID(SUBSTITUTE(A2,"-",),4,1)*10+MID(SUBSTITUTE(A2,"-",),5,1)*9+MID(SUBSTITUTE(A2,"-",),6,1)*8+MID(SUBSTITUTE(A2,"-",),7,1)*7+MID(SUBSTITUTE(A2,"-",),8,1)*6+MID(SUBSTITUTE(A2,"-",),9,1)*5+MID(SUBSTITUTE(A2,"-",),10,1)*4+MID(SUBSTITUTE(A2,"-",),11,1)*3+MID(SUBSTITUTE(A2,"-",),12,1)*2,11)))
|