如何在Excel中创建SUM IF BOLD公式?

问题描述 投票:0回答:1

我想创建一个公式,结合 SUM IF (SUMMEWENN) 和 SUMBOLD (SUMMEFETT) 函数。

我已经从here找到了一个SUMBOLD公式,但我不知道如何创建SUMIFBOLD(SUMMEWENNFETT)公式,有人可以告诉我vba代码吗? 谢谢你。

excel vba excel-formula sumifs
1个回答
0
投票

这是函数:

函数 SumIfBold(rng_crit 作为范围,rng_sum 作为范围) As Double 总计暗淡为双倍 昏暗我只要

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

结束功能

© www.soinside.com 2019 - 2024. All rights reserved.