【问题标题】:I have a countcolour (VB script) result, how do I obtain a countif result within that result我有一个 countcolour(VB 脚本)结果,如何在该结果中获得一个 countif 结果
【发布时间】:2017-11-14 12:17:33
【问题描述】:

我在 VB 中使用了 =countcolour 脚本,最终得到了结果。例如,“=countcolour(a1:a10,b1)” b1 可以说是绿色,结果是 6 个绿色单元格。 我想知道的是,如果在“A1:A10”中随机输入了一个单元格值“G”,我该如何计算countcolor结果中的“G”?

【问题讨论】:

  • 如果您使用 excel,它不是 VB.NET。标签上的文字提供了使用指南。请阅读How to Ask 并采取tour

标签: excel vb.net multiple-results


【解决方案1】:

我不确定我是否理解您所追求的,但如果它相当于 COUNTIFS 工作表公式,则以下代码将起作用:

Sub SumCountByConditionalFormat()
Dim refColor As Long
Dim rng As Range
Dim countRng As Range
Dim countCol As Long

Set countRng = Sheet1.Range("$A$1:$A$10")

    refColor = Sheet1.Range("$B$1").DisplayFormat.Interior.Color
    For Each rng In countRng
        If rng.DisplayFormat.Interior.Color = refColor And rng.Value = "g" Then
            countCol = countCol + 1
        End If
    Next
    MsgBox countCol

End Sub

【讨论】:

    猜你喜欢
    • 2013-07-29
    • 2021-07-14
    • 1970-01-01
    • 2020-08-22
    • 1970-01-01
    • 2018-05-15
    • 2021-07-17
    • 1970-01-01
    • 2020-08-22
    相关资源
    最近更新 更多