|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
做了前三个问题,第四个觉得没啥实际意义,也简单没做。代码未经测试。- Sub shishi()
- Dim brr
- Set dic = CreateObject("scripting.dictionary")
- arr = Sheet2.Range("a1").CurrentRegion
- For i = 2 To UBound(arr)
- Key = arr(i, 1) & "|" & arr(i, 4)
- If Not dic.exists(Key) Then
- dic(Key) = i
- Else
- dic(Key) = dic(Key) & ";" & i
- End If
- Next
- ReDim brr(1 To dic.Count, 1 To 5)
- For Each Key In dic.keys
- ss = Split(dic(Key), ";")
- n1 = 0: n2 = 0: s = 0: s1 = 0: s2 = 0
- For j = 0 To UBound(ss)
- If arr(ss(j), 5) = "血氧饱和度监测费" Or arr(ss(j), 5) = "指脉氧监测费" Then s = s + Val(arr(ss(j), 9))
- If arr(ss(j), 5) = "胃肠减压" Then n1 = n1 + 1: s1 = s1 + Val(arr(ss(j), 9))
- If arr(ss(j), 5) = "二级医院普通床位费" And arr(ss(j), 9) > 40 Then n2 = n2 + 1: s2 = s2 + Val(arr(ss(j), 9))
- Next
- n = n + 1
- brr(n, 1) = Split(Key, "|")(0): brr(n, 2) = Split(Key, "|")(1): brr(n, 3) = s
- If n1 > 1 Then brr(n, 4) = s1: If n2 > 1 Then brr(n, 5) = s2
-
- Next
- End Sub
复制代码 |
|