|
例えば、統合と並べ替えの機能で可能です。
マクロを使うまでもないと思いますが。
Option Explicit
Sub test()
Dim 統合先 As Range, 統合元 As Range
Set 統合先 = ActiveSheet.Columns("H:I")
Set 統合元 = ActiveSheet.Columns("E:F")
統合先.ClearContents
With 統合先
.Consolidate _
Sources:=統合元.Address(ReferenceStyle:=xlR1C1), _
Function:=xlSum, _
TopRow:=False, _
LeftColumn:=True
End With
With ActiveSheet.Sort.SortFields
.Clear
.Add Key:=統合先.Cells(1)
End With
With ActiveSheet.Sort
.SetRange 統合先
.Header = xlNo
.Apply
End With
End Sub
Sub test2()
'
Dim 統合先 As Range, 統合元 As Range
Set 統合先 = ActiveSheet.Columns("K:L")
Set 統合元 = ActiveSheet.Columns("E:F")
統合先.Columns(2).ClearContents
With 統合先
.Consolidate _
Sources:=統合元.Address(ReferenceStyle:=xlR1C1), _
Function:=xlSum, _
TopRow:=False, _
LeftColumn:=True
End With
End Sub
|
|