以下是这种情况:
这里的closest questions I've found似乎都依赖于R,但有没有办法在Excel中执行此操作?
编辑:这里有一些简化的样本数据(实际数据包含更多列)和所需的结果:
数据来源1:
Type Date Num Name Split Amount
Deposit 01/01/2014 wire John Doe Town Bank $1234.56
Deposit 01/06/2014 wire Jane Doe Village Bank $3434.65
Check 02/24/2014 clr Jim Doe City Bank -$4000.00
数据来源2:
Type Date Num Name Split Amount
Deposit 12/11/2013 45 John Doe Town Bank -$25.56
Deposit 12/25/2013 wire Jane Doe Village Bank $334.65
Deposit 01/11/2014 45 John Doe Town Bank -$25.56
Deposit 01/14/2014 wire Jane Doe Village Bank $108.00
Deposit 01/27/2014 wire Jane Doe Village Bank $314.15
Deposit 02/11/2014 45 John Doe Town Bank -$25.56
Deposit 02/13/2014 wire Jane Doe Village Bank $2.15
期望的结果:
Type Date Num Name Split Amount
Deposit 12/11/2013 45 John Doe Town Bank -$25.56
Deposit 12/25/2013 wire Jane Doe Village Bank $334.65
Deposit 01/01/2014 wire John Doe Town Bank $1234.56
Deposit 01/06/2014 wire Jane Doe Village Bank $3434.65
Deposit 01/11/2014 45 John Doe Town Bank -$25.56
Deposit 01/14/2014 wire Jane Doe Village Bank $108.00
Deposit 01/27/2014 wire Jane Doe Village Bank $314.15
Deposit 02/11/2014 45 John Doe Town Bank -$25.56
Deposit 02/13/2014 wire Jane Doe Village Bank $2.15
Check 02/24/2014 clr Jim Doe City Bank -$4000.00
答案 0 :(得分:0)
这样的事情应该有效:
Sub Tester()
Dim rng1 As Range, rng2 As Range, cr As Range
Set rng1 = Worksheets("Sheet1").Range("A1").CurrentRegion
Set rng1 = rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1) 'omit headers
Set rng2 = Worksheets("Sheet2").Range("A1").CurrentRegion
Set rng2 = rng2.Offset(1, 0).Resize(rng2.Rows.Count - 1) 'omit headers
With Worksheets("Summary")
Set cr = .Range("A1").CurrentRegion
cr.Offset(1, 0).ClearContents 'clear existing data
rng1.Copy .Range("A2")
rng2.Copy .Range("A2").Offset(rng1.Rows.Count)
With .Sort
.SortFields.Clear
.SortFields.Add Key:=cr.Columns(2), _
SortOn:=xlSortOnValues, _
Order:=xlAscending, _
DataOption:=xlSortNormal
.SetRange cr
.Header = xlYes
.MatchCase = False
.Apply
End With
End With
End Sub