[英]Excel VBA update links in workbook to same destination
My issue: 我的问题:
I have a sheet, where I compare two sets of data. 我有一张工作表,在这里我比较两组数据。 These two sets of data, are might have some with the same description number... 这两组数据可能有一些具有相同的描述编号...
In this case I want them to merge, but at the moment I do it manually.. 在这种情况下,我希望它们合并,但是现在我手动进行。
My data looks like in both ranges: 我的数据看起来在两个范围内:
Date Description Amount
15-12-2017 V576954 -1.289,89
15-12-2017 V576954 1.289,89
15-12-2017 V576954 -1.896,45
19-12-2017 V586894 -789,52
28-12-2017 GS5155692 -9.286,00
28-12-2017 GS5155692 9.286,00
28-12-2017 GS5155692 -11.857,50
GOAL: 目标:
Is there somehow, that I can pull out the Functions a Pivot Table is using, and sum up the values with the same description?? 是否可以以某种方式提取出数据透视表正在使用的功能,并用相同的描述总结这些值?
I don't want to get a Pivot Table out of my data, I want to merge the values of the values, which has the same description, along as having the same Date, and the same description :) 我不想从数据中获取数据透视表,而是要合并具有相同描述,相同日期和相同描述的值的值:)
If I understand your question correctly, you want to sum the values on Column C if the data in Column A and B match, then the following would do that for you: 如果我正确理解了您的问题,那么如果列A和列B中的数据匹配,则希望对列C中的值求和,那么下面的操作将为您完成:
Sub foo()
Sheets("Sheet1").Copy After:=Sheets("Sheet1")
ActiveSheet.Name = "Summary"
Dim ws As Worksheet: Set ws = Sheets("Summary")
'declare and set your worksheet, change Sheet1 to the sheet you are using
LastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
'find the last row with data on Column A
For i = 2 To LastRow 'loop from row 2 to last
ws.Cells(i, 4).FormulaR1C1 = "=SUMIFS(C[-1],C[-2],RC[-2],C[-3],RC[-3])" 'enter sum formula in adjecent cell (Column D)
Next i
ws.Range("D2:D" & LastRow).Copy 'copy the formula
ws.Range("D2:D" & LastRow).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False 'paste as values
Range("C2:C" & LastRow).Delete Shift:=xlToLeft 'delete column C and shift the values from column D to column C
ws.Range("$A$1:$D$" & LastRow).RemoveDuplicates Columns:=Array(1, 2, 3, 4), Header:=xlYes 'remove duplicate rows
End Sub
You can use Power Pivot it is a free add-in that you can get and easily activate. 您可以使用Power Pivot,它是一个免费加载项,您可以获取并轻松激活它。 Get & Transform by default in Excel 2016. 默认情况下在Excel 2016中获取和转换 。
It will open the Query Editor there: 它将在此处打开查询编辑器 :
[Date]
and [Description]
选择[Date]
和[Description]
You can connect many sources to Power Query and it will be a right click Refresh and you will have your process done! 您可以将许多源连接到Power Query ,只需右键单击“ 刷新”即可完成您的过程!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.