试试这个功能
Function SumIfColMatch(ByVal matchRow As Integer, ByVal matchString As String, ByVal sumRange As Range, ByVal maxToCount As Integer)
Dim dblTotal As Double
Dim lngCounter As Long
Dim sumCount As Integer
sumCount = 0
For lngCounter = sumRange.Cells.Count To 1 Step -1
If Cells(matchRow, lngCounter).Value Like matchString Then
dblTotal = dblTotal + sumRange(lngCounter).Value
sumCount = sumCount + 1
If sumCount >= maxToCount Then Exit For
End If
Next lngCounter
SumIfColMatch = dblTotal
End Function
In the formula cell use something like this =SumIfColMatch(1,"Q*/201*",A3:DL3,12)
它对我有用,请参见附件截图
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句