|
楼主 |
发表于 2023-4-28 21:30
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
不知道这段代码哪里出了问题,始终无法获取重复的号码。
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
Set shthz = ThisWorkbook.Sheets("汇总1")
H = shthz.UsedRange.Rows.Count
L = shthz.UsedRange.Columns.Count
arrzhy = shthz.Range(shthz.Cells(1, 1), shthz.Cells(H, L))
m = 0
For z = 1 To L
For x = 1 To L
If arrzhy(2, z) = arrzhy(2, x) Then GoTo 66
For y = 3 To H
If arrzhy(y, x) = "" Then GoTo 66
If arrzhy(y, z) = "" Then GoTo 99
If arrzhy(y, z) = arrzhy(y, x) Then
m = m + 1
ReDim Preserve arrkyhy(1 To m, 1 To 3)
arrkyhy(m, 1) = arrzhy(y, z)
arrkyhy(m, 2) = arrzhy(2, z) & "_" & arrzhy(2, x)
arrkyhy(m, 3) = arrzhy(1, z) & "_" & arrzhy(1, x)
End If
Next y
66:
Next x
99:
Next z
ThisWorkbook.Sheets(2).Range("B2").Resize(UBound(arrkyhy), 3) = arrkyhy
Erase arrzhy
Erase arrkyhy()
Set shthz = Nothing
End Sub
|
|