|
こんにちは
データシート=Sheet1
集計シート=Sheet2
と設定しています(そちらの環境に合わせてください)
ではお試しを。
Sub test_1()
Dim Ws As Worksheet, Fi As Range, R As Range, C As Range, Ad As String
Set Ws = Worksheets("Sheet2")
Application.ScreenUpdating = False
With Worksheets("Sheet1")
.Columns(1).AdvancedFilter xlFilterInPlace, , , True
.Range("A2", .Range("A65536").End(xlUp)) _
.SpecialCells(xlCellTypeVisible).Copy Ws.Range("E14")
.ShowAllData
Set R = Ws.Range("E14", Ws.Range("E65536").End(xlUp))
For Each C In R
Set Fi = .Columns(1).Find(C.Value, , xlValues, xlWhole)
If Not Fi Is Nothing Then
Ad = Fi.Address
Do
Set Fi = .Columns(1).FindNext(Fi)
Fi.Offset(, 1).Resize(, 4).Copy
C.Offset(, 1).PasteSpecial xlPasteValues, xlPasteSpecialOperationAdd
Loop Until Ad = Fi.Address
End If
Set Fi = Nothing
Next C
Application.CutCopyMode = False
End With
Application.ScreenUpdating = True
Set R = Nothing: Set Ws = Nothing
End Sub
|
|