如何组合重复的行,并在Excel中求和值3列 [英] how to combine duplicate rows and sum the values 3 column in excel

查看:257
本文介绍了如何组合重复的行,并在Excel中求和值3列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



大家好,
我有一个问题来创建VBA excel来复制数据。 / p>

如何组合重复的行,并将excel中的值3列加起来?



谢谢。

解决方案

这个使用删除重复:

 code> Sub dupremove()
Dim ws As Worksheet
Dim lastrow As Long

设置ws = Sheets(Sheet1)'更改为您的工作表

带有ws
lastrow = .Range(A& .Rows.Count).End(xlUp).Row
带.Range(B2:C& lastrow)
.Offset(,4).FormulaR1C1 == SUMIF(C1,RC1,C [-4])
.Offset(,4).Value = .Offset(,4).Value
结束
带.Range(A1:A& lastrow)
.Offset(,4).Value.Value = .Value
结束
。 Range(E1:G& lastrow).RemoveDuplicates 1,xlYes

End with

End Sub


Hello everyone, I have a problem to create VBA excel to duplicate data.

How to combine duplicate rows and sum the values 3 column in excel?

Thank you.

解决方案

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆