|
楼主 |
发表于 2023-5-22 13:44
|
显示全部楼层
老师,你5楼作品就很好!优化后反而出现问题,把标题也给一起删除了。还是以下代码好。
Sub dd()
Dim d As Object, arr, brr, i&, j&, k
Set d = CreateObject("scripting.dictionary")
arr = Range("e1:g" & [a65536].End(xlUp).Row)
For i = 11 To UBound(arr)
If Len(arr(i, 1)) = 18 And arr(i, 2) <> 0 Then
d(arr(i, 1)) = d(arr(i, 1)) & "," & i
End If
Next
ReDim brr(1 To UBound(arr), 1 To 1)
For i = 1 To UBound(arr)
k = Mid(Replace(d(arr(i, 1)), "," & i, ""), 2)
If Len(k) And arr(i, 2) <> 0 Then
brr(i, 1) = "与第" & k & "行重复"
Else
brr(i, 1) = Range("h" & i).Value
End If
Next
[h1].Resize(UBound(arr) - 1, 1) = brr
Set d = Nothing
End Sub
|
|