|
'こんな事?
Option Explicit
Public Sub Sample()
Dim i As Long
Dim j As Long
Dim vntData As Variant
Dim dicIndex As Object
Dim vntResult As Variant
Dim strProm As String
'Dictionaryオブジェクトを取得
Set dicIndex = CreateObject("Scripting.Dictionary")
vntData = Range(Cells(2, "B"), Cells(Rows.Count, "B").End(xlUp)).Value
With dicIndex
For i = 1 To UBound(vntData, 1)
.Item(vntData(i, 1)) = 1
Next i
End With
vntData = Range(Cells(2, "A"), Cells(Rows.Count, "A").End(xlUp)).Value
With dicIndex
For i = 1 To UBound(vntData, 1)
If .Exists(vntData(i, 1)) Then
.Item(vntData(i, 1)) = .Item(vntData(i, 1)) + 1
End If
Next i
End With
vntData = Range(Cells(2, "C"), Cells(Rows.Count, "C").End(xlUp)).Value
With dicIndex
For i = 1 To UBound(vntData, 1)
If .Exists(vntData(i, 1)) Then
.Item(vntData(i, 1)) = .Item(vntData(i, 1)) + 1
End If
Next i
End With
With dicIndex
vntData = .Keys
ReDim vntResult(1 To UBound(vntData) + 1, 1 To 2)
For i = 0 To UBound(vntData)
If .Item(vntData(i)) > 1 Then
j = j + 1
vntResult(j, 1) = vntData(i)
vntResult(j, 2) = .Item(vntData(i))
End If
Next i
End With
Cells(2, "E").Resize(j, 2).Value = vntResult
Set dicIndex = Nothing
MsgBox "処理が完了しました", vbInformation
End Sub
|
|