I want to create a formula, that combines the SUM IF (SUMMEWENN) and a SUMBOLD (SUMMEFETT) functions.
我想创建一个公式,它结合了SUM IF(SUMMEWENN)和一个SUMBOLD(SUMMEFETT)函数。
I already found a SUMBOLD formula from here but I don't know how to create the SUMIFBOLD (SUMMEWENNFETT) formula, can anyone tell me the vba-code?
Thank you.
我已经从这里找到了一个SUMBOLD公式,但我不知道如何创建SUMIFBOLD(SUMMEWENNFETT)公式,有人能告诉我VBA代码吗?谢谢。
更多回答
The code you point at has an if statement: If IsNumeric(Zelle.Value) Then Summe = Summe + Zelle.Value
so all you need to do is add and conditions to it.
您所指向的代码有一条if语句:If IsNumeric(Zelle.Value)Then Summe=Summe+Zelle.Value,因此您所需要做的就是向其添加AND条件。
What is not working with code you point at? How have you tried to modify it? And what's your condition for SUM IF?
您所指的代码中有什么不起作用?你是如何尝试修改它的?你求和的条件是什么?
优秀答案推荐
Here is the function:
以下是其功能:
Function SumIfBold(rng_crit As Range, rng_sum As Range) As Double
Dim Total As Double
Dim i As Long
Total = 0 ' Initialize the total to zero
' Check if both ranges have the same number of cells
If rng_crit.Cells.Count <> rng_sum.Cells.Count Then
SumIfBold = 0 ' Return 0 if the ranges don't match
Exit Function
End If
For i = 1 To rng_crit.Cells.Count
If rng_crit.Cells(i).Font.Bold = True Then
Total = Total + rng_sum.Cells(i).Value
End If
Next i
SumIfBold = Total ' Return the total
End Function
更多回答
我是一名优秀的程序员,十分优秀!