【发布时间】:2018-08-02 18:28:57
【问题描述】:
此函数的目标是根据不同范围内其他单元格的值和位置对某个范围内的特定单元格求和。
这是一张图片,所以更清楚:
第 M 列的答案是 = 2+4+6+9 = 21 P 列的答案是 = 3+7+10 = 20
“Licitante 1, Licitante 2, ...”下有 20 种不同的“Precio, Precio2, Precio3,...”,这就是我使用 CASES 的原因。
回顾一下,如果“M”列中的一个单元格 >0,那么函数应该选择同一行上的“H”列上的单元格,对所述范围内的所有单元格执行此操作并添加它们。
到目前为止我有这个:
Function ImporteLic(lic As String)
Dim cell As Range
Dim i As Integer
Select Case lic
Case "Licitante 1"
For Each cell In Range("M13:M50")
If ActiveCell.Value > 0 Then
ActiveCell.Offset(0, -5) = i
End If
Next cell
ImporteLic = worksheetfuntion.Sum(i)
End Select
End Function
我想我在满足条件的所有单元格加起来的部分中遗漏了一些东西。
感谢您的帮助。
【问题讨论】:
-
你试过Application.SUMIFS()吗?