凡是需要实现Countifs或者Sumifs的功能,用字典做再合适不过了Sub Test()
On Error Resume NextDim Dic As Object, Stri As String, i As IntegerSet Dic = CreateObject(Scripting.Dictionary)
For i = 1 To Cells(Rows.Count, 1).End(3).Row I360问答f Cells(i, 1) = And Cells(i, 3) = Then GoTo Nexti: Stri = Cells(i, 1) & {*} & Cells(i, 3) If Dic.Exists(Stri) Then Dic(Stri) = Dic(Stri) + Cells(i, 2) Else Dic(Stri) = Cells(i, 2)Nexti:Next
For i = 1 To Cells(Rows.Count, 6).End(3).Row Stri = Cells(i, 6) & {*} & Cells(i, 8) Cells(i, 7) = Dic(Stri)Next
Set Dic = NothingEnd Sub测试无误
Copyright © 2025 IZhiDa.com All Rights Reserved.
知答 版权所有 粤ICP备2023042255号