用代码总结Excel

我在木工行业工作。 我想在Excel中使用可重用的工作表来加快我的工作stream程。 我正在做材料报价,总结所有build立橱柜所需要的东西。 这些橱柜通常是定制橱柜,我必须把所有的尺寸,数量等都写在我的手里,在做完之后我必须总结一下数据来做出报价。 我在Blender python中做了一个脚本,工作正常,但我需要在Excel工作表中做。 我的问题是:我写下了一块电路板(有四面)的尺寸。 没有问题得到平方米我只是简单地乘以数字。 但是我有一个叫做“Edgebanding”的单元格。 我们使用两种types:1称为PVC(小写字母)2称为ABS(大写字母)。 总结这些,我需要一个代码(我现在编码为8年)。 我只是简单地写下我所需要的代码:

SUMPVC = 0 for length of string(Edgebanding cell) with each letter if currentLetter='a' then SUMPVC+=BoardWidth(B Cell value) elif currentLetter='b' SUMPVC+=BoardHeight(D Cell value) end for cycle return width SUMPVC*Quantity(F cell value)

SUMABS = 0 for length of string(Edgebanding cell) with each letter if currentLetter='A' then SUMABS+=BoardWidth(B Cell value) elif currentLetter='B' SUMABS+=BoardHeight(D Cell value) end for cycle return width SUMABS*Quantity(F cell value)

是否有可能(如果是这样的话?)将其作为一个像Excel中其他运算符一样的函数(如“= SUM(range)”)。

所以看起来像“= SUMPVC(E2)”和“= SUMABS(E2)

我附上截图,只是为了清楚我在说什么。 提前致谢! Alex 例子

我没有50以上的声望,所以我不能发表这个评论:

在上面的链接中,有一个关于如何创build公式的小教程。 只是适应你的需要。

http://www.dummies.com/software/microsoft-office/excel/how-to-create-custom-excel-functions/