Excel 用代码总结

Excel summarizing with code

我在木工行业工作。我想在 excel 中使用可重复使用的工作表来加快我的工作流程。我正在制作 material 报价,总结我们建造橱柜所需的所有东西。这些柜子一般都是定做柜子,尺寸、数量等都得手写,写完之后还要汇总数据再报价。我在 Blender python 中编写了一个脚本,效果很好,但我也需要在 Excel 工作表中执行。我的问题: 我记下了板子的尺寸(有 4 个面)。 得到平方米没问题我只是简单地乘以数字。但我有一个名为 "Edgebanding" 的单元格。我们用的有两种:1叫PVC(small letters)2叫ABS(capital letters)。为了总结这些,我需要一个代码(我现在已经编码 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)

我附上截图,只是为了清楚我在说什么。 提前致谢!亚历克斯 Example

我没有 50+ 的声誉,所以我不能 post 这作为评论:

在上面的link中,有一个关于如何创建公式的小教程。适应你的需要。

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