如何在 Excel 中创建 fifo 函数
我需要创建一个 fifo 函数来计算价格。
我有一个具有以下布局的表格:
Purchase_date Quantity Purchase_Price
----------------------------------------
2011-01-01 1000 10
2011-01-02 2000 11
......
Sale_date Quantity Costprice
----------------------------------------
2011-02-01 50 =fifo_costprice(...
Fifo 公式的工作原理如下:
fifo_costprice(Q_sold_to_date as float, Quantity_purchased as range
, Purchase_Prices as range) as float
如何在 Excel VBA 中执行此操作?
I need to create a fifo function for price calculation.
I have a table with the following layout:
Purchase_date Quantity Purchase_Price
----------------------------------------
2011-01-01 1000 10
2011-01-02 2000 11
......
Sale_date Quantity Costprice
----------------------------------------
2011-02-01 50 =fifo_costprice(...
the Fifo formula works like:
fifo_costprice(Q_sold_to_date as float, Quantity_purchased as range
, Purchase_Prices as range) as float
How do I do this in Excel VBA?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是我想出的开始,它不进行任何错误检查和日期匹配,但它有效。
Here's what I came up with to start, it doesn't do any error checking and date matching, but it works.
我在通过 VBA 查找“最新汇率”时遇到了类似的问题。这是我的代码,也许它可以启发您...
它更像是一个带有循环索引(
Idx as Integer
)和两个退出条件的经典循环构造,因此我不需要遍历 < 所有情况下的所有行。I had a similar problem finding the "most recent exchange rate" via VBA. This is my code, maybe it can inspire you ...
It's more a classical loop construct with a loop index (
Idx as Integer
) and two exit criteria, so I don't need to go across all rows under all circumstances.