问题描述
我试图找出如何根据不同列的值添加一个总和的行。当我这样做,我想删除添加到该值的行,并保留一行。
I am trying to figure out how I can add a row with a sum based on the values of a different column. When I do this, I'd like to remove the rows that added up to that value and retain just one row.
例如,列A有PO 10404,PO 10404,PO 10404,PO 10404,PO 10405,PO 10405.我想在PO 10404和PO 10405之间添加一行,然后将两个PO的美元金额(我猜到一个SumIf的)相加,然后删除单行,只保留一行。我需要共同的内容,如PO号码。
For instance, Column A has PO 10404, PO 10404,PO 10404,PO 10404, PO 10405, PO 10405. I'd like to add a row in between PO 10404 and PO 10405 and then sum the dollar amounts of both PO's (I'm Guessing with a SumIf's) and then delete the individual line and just keep the one line with the total. I would need the contents of the common line, like the PO number.
谢谢!
Joe
Thanks!Joe
推荐答案
您可以使用数据透视表执行此操作。使用PO#作为行标签,并将这些值用作销售金额(或任何该列所称的值)的总和。
You could do this with a Pivot Table. Use "PO#" as your row label and Sum of "Sale Amount" (or whatever that column is called) for the values.
编辑:自动化此功能的实用提示作为宏:
Helpful tips for automating this as macro:
然后自动保存为CSV:
Then to automate saving as a CSV:
ActiveWorkbook.SaveAs Filename:= _
"c:\MyFile.csv", FileFormat:=xlCSV _
, CreateBackup:=False
这篇关于Excel VBA添加小计和删除行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!