|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
参考一下:
Option Explicit
Option Base 1
Sub 查找相同ID()
Dim arrzhy(), arrkyhy()
Dim x As Long, y As Long, z As Long, H As Long, L As Long, m As Long
Dim shthz As Worksheet
Dim a
Dim b
Dim c
Set shthz = ThisWorkbook.Sheets("汇总1")
H = shthz.UsedRange.Rows.Count
L = shthz.UsedRange.Columns.Count
ReDim arrkyhy(1 To H, 1 To 4)
arrzhy = shthz.Range(shthz.Cells(1, 1), shthz.Cells(H, L))
m = 0
For z = 3 To H
a = arrzhy(z, 1)
For x = 3 To H
b = arrzhy(x, 2)
If a = b Then
For y = 3 To H
c = arrzhy(y, 3)
If b = c Then
m = m + 1
arrkyhy(m, 1) = arrzhy(y, 3)
arrkyhy(m, 2) = arrzhy(2, 1) & "_" & arrzhy(1, 1)
arrkyhy(m, 3) = arrzhy(2, 2) & "_" & arrzhy(1, 2)
arrkyhy(m, 4) = arrzhy(2, 3) & "_" & arrzhy(1, 3)
End If
Next
End If
Next
Next
ThisWorkbook.Sheets(2).Range("B2").Resize(H, 4) = arrkyhy
Erase arrzhy
Erase arrkyhy()
Set shthz = Nothing
End Sub
|
|