如何组合重复的行并在excel中对3列的值求和 [英] how to combine duplicate rows and sum the values 3 column in excel
本文介绍了如何组合重复的行并在excel中对3列的值求和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我在创建 VBA excel 以复制数据时遇到问题.
Hello everyone, I have a problem to create VBA excel to duplicate data.
如何在excel中合并重复的行并对3列的值求和?
How to combine duplicate rows and sum the values 3 column in excel?
谢谢.
推荐答案
这个使用 Remove Duplicates:
this one uses Remove Duplicates:
Sub dupremove()
Dim ws As Worksheet
Dim lastrow As Long
Set ws = Sheets("Sheet1") ' Change to your sheet
With ws
lastrow = .Range("A" & .Rows.Count).End(xlUp).Row
With .Range("B2:C" & lastrow)
.Offset(, 4).FormulaR1C1 = "=SUMIF(C1,RC1,C[-4])"
.Offset(, 4).Value = .Offset(, 4).Value
End With
With .Range("A1:A" & lastrow)
.Offset(, 4).Value.Value = .Value
End with
.Range("E1:G" & lastrow).RemoveDuplicates 1, xlYes
End With
End Sub
这篇关于如何组合重复的行并在excel中对3列的值求和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文