|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
参与一下。。。- Sub ykcbf() '//2024.1.26
- Dim arr, brr, d
- Set d = CreateObject("Scripting.Dictionary")
- r = Me.Cells(Rows.Count, 1).End(3).Row
- arr = Me.Range("a1:g" & r)
- For i = 2 To UBound(arr)
- s = arr(i, 1)
- If arr(i, 2) <> Empty Then
- If Not d.exists(s) Then
- d(s) = Array(1, arr(i, 2))
- Else
- t = d(s)
- t(0) = t(0) + 1
- t(1) = t(1) & "," & arr(i, 2)
- d(s) = t
- End If
- End If
- Next
- Me.[d2:f10000] = ""
- For i = 2 To UBound(arr)
- s = arr(i, 1)
- If d.exists(s) Then
- If Val(arr(i, 3)) Then
- arr(i, 4) = d(s)(0)
- arr(i, 5) = d(s)(1)
- arr(i, 6) = Val(arr(i, 3)) - arr(i, 4)
- Else
- arr(i, 4) = ""
- arr(i, 5) = ""
- arr(i, 6) = ""
- End If
- End If
- Next
- Me.Range("a1:g" & r) = arr
- Set d = Nothing
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|