【发布时间】:2014-10-28 20:54:14
【问题描述】:
我在 Excel 2011 中使用 VBA(但保存到 Excel 97 - 2004)来计算 C 列中值为training 的所有匹配值。为此,我使用以下代码:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1" Then
Dim r As Range
Dim c
Set r = Sheets("Sheet2").Range("C:C")
c = Application.WorksheetFunction.CountIf(r, "training")
MsgBox "column C has " & c & " instances of 'training'"
End If
End Sub
但是我想做的是创建一个 CountIfs 语句,它允许我检查值“training”是否存在于 C 列中,以及值 10 是否存在于另一个 B 列中,如果两者在同一行中匹配,那么计算两个值都存在的所有行,否则不计算。
有人能帮我解决这个问题吗?
【问题讨论】:
-
我目前使用 excel for mac 2011,但我将工作簿保存在 excel 97 到 2004 中,因为它需要与 windows 中的 excel 2010 兼容
标签: excel vba count excel-2011