Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想创建一个宏来执行以下操作:在 Excel 表中
A B C ------ a b c d
C例如,我将在列中粘贴数据
C
A B C ------ a b b b c f d
我正在寻找的结果是找到匹配的数量,A如果B不匹配,则将元素添加到列A中,如下所示:
A
B
A B C ----- a b b 2 b c f d f 1
该子例程将计算 C 列中匹配项的数量,并在 B 列中打印结果。
Sub MatchColumnAtoColumnC() Dim rngA as Range Dim rngC as Range Dim cl as Range Set rngA = Range("A1",Range("A1").End(Xldown)) Set rngC = rngA.Offset(0,2) For Each cl in rngA cl.Offset(0,1).Value = CountIf(cl,rngC) Next End Sub