你的公式是要得到指定i,统计cells(i,5)在E列且cells(i,6)在F列出现的次数,你的用意可能是要找出EF列记录重复的记录.如果我理解错了或有不明白的地方,请Hi我吧!
我做了两个函数可以实现:
1,zxc()以i为参数返回cells(i,5)且cells(i,6)出现的次数
2.mxb()以单元格为参数返回cells(i,5)且cells(i,6)出现的次数
Function zxc(i As Integer) As Integer
'指定i,统计cells(i,5)在E列且cells(i,6)在F列出现的次数
cnt = 0
If i > 1 Then
R = Range("E65535").End(xlUp).Row
Tmp1 = Cells(i, 5).Value
Tmp2 = Cells(i, 6).Value
For j = 2 To R
If Cells(j, 5).Value = Tmp1 And Cells(j, 6).Value = Tmp2 Then
cnt = cnt + 1
End If
Next
End If
zxc = cnt
End Function
Function mxb(addr As Range) As Integer
'指定i,统计cells(i,5)在E列且cells(i,6)在F列出现的次数
cnt = 0
i = addr.Row
R = Range("E65535").End(xlUp).Row
Tmp1 = Cells(i, 5).Value
Tmp2 = Cells(i, 6).Value
For j = 2 To R
If Cells(j, 5).Value = Tmp1 And Cells(j, 6).Value = Tmp2 Then
cnt = cnt + 1
End If
Next
zxc1 = cnt
End Function