Sub aa()
Dim rng, rnge As Range
Dim i As Integer
i = 1
For Each rng In range("d"&activesheet.usedrange.rows.count)
For Each rnge In range("g"&activesheet.usedrange.rows.count)
If rng.Value = rnge.Value Then
ActiveSheet.Range("k" & i).Value = rng
i = i + 1
End If
Next
Next
End Sub
如果数据太多建议改成数组