本帖最后由 417744370 于 2024-2-9 15:15 编辑
想得到的结果图
原数据图
Sub 测试()
Dim Arr, Brr(), i%, n%, Dic As Object
Set Dic = CreateObject("scripting.dictionary")
Sheets("Sheet1").Cells.Clear
Arr = Sheets("原表").UsedRange
ReDim Brr(1 To UBound(Arr), 1 To 16)
For i = 1 To UBound(Arr)
Dic(Arr(i, 3)) = Dic(Arr(i, 3)) + 1
If Dic(Arr(i, 3)) > 1 Then ‘此条件只显示大于1的数据。若输入Dic(Arr(i, 3)) =Arr(i, 3)无效
n = n + 1
Brr(n, 1) = Arr(i, 1)
Brr(n, 2) = Arr(i, 2)
Brr(n, 3) = Arr(i, 3)
Brr(n, 4) = Arr(i, 4)
Brr(n, 5) = Arr(i, 5)
Brr(n, 6) = Arr(i, 6)
Brr(n, 7) = Arr(i, 7)
Brr(n, 8) = Arr(i, 8)
Brr(n, 9) = Arr(i, 9)
Brr(n, 10) = Arr(i, 10)
Brr(n, 11) = Arr(i, 11)
Brr(n, 12) = Arr(i, 12)
Brr(n, 13) = Arr(i, 13)
Brr(n, 14) = Arr(i, 14)
Brr(n, 15) = Arr(i, 15)
Brr(n, 16) = Arr(i, 16)
End If
Next i
Sheets("Sheet1").[a2].CurrentRegion.ClearContents
Sheets("Sheet1").Range("A1").Resize(1, 16) = Array("客户编号", "企业名称", "真实姓名", "手机号", "注册身份证", 0, "受理地市", "委托起始日", "委托到期日", "客户经理", "客户经理手机", "提交日期", "提交时间", "授权证明", "身份证", "企业编号")
Sheets("Sheet1").[a2].Resize(n, 16) = Brr
End Sub
|