Sub filter()
Dim m& ' 找到的数据组数
Dim nj% ' 数据列数
Dim i& ' 行循环
Dim j& ' 行+1
Dim k& ' 列循环
ni = 9 ' 数据总行数-------输入
nj = 8 ' 数据总列数-------输入
m = 0
For i = 1 To ni
j = i + 1
If Sheet1.Cells(i, 1) = Sheet1.Cells(j, 1) And Sheet1.Cells(i, 2) = Sheet1.Cells(j, 2) Then
m = m + 1
For k = 1 To nj
Sheet2.Cells(2 * m - 1, k) = Sheet1.Cells(i, k)
Sheet2.Cells(2 * m, k) = Sheet1.Cells(j, k)
Next k
End If
Next i
End Sub
|