|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub ssjss() 'wzq 2023.7.3
- Dim arr, brr, d, i&, T
- Set d = CreateObject("scripting.dictionary")
- With Sheets("数据")
- r = .Cells(Rows.Count, 1).End(xlUp).Row
- arr = .Range("a1:i" & r)
- End With
- Sheet1.Activate
- [a7:K60000] = ""
- '问题一
- For i = 2 To UBound(arr)
- If 0 < InStr(arr(i, 5), "血氧饱和度监测") Then
- T = arr(i, 1)
- If Not d.exists(T) Then
- d(T) = Array(arr(i, 9), 1, 0)
- Else
- d(T) = Array(d(T)(0) + arr(i, 9), d(T)(1) + 1, d(T)(2))
- End If
- End If
- If 0 < InStr(arr(i, 5), "指脉氧监测") Then
- T = arr(i, 1)
- If Not d.exists(T) Then
- d(T) = Array(arr(i, 9), 0, 1)
- Else
- d(T) = Array(d(T)(0) + arr(i, 9), d(T)(1), d(T)(2) + 1)
- End If
- End If
- Next
- ReDim brr(1 To d.Count, 1 To 2)
- i = 0
- If d.Count > 0 Then
- For Each T In d.keys
- If d(T)(1) > 0 And d(T)(2) > 0 Then
- i = i + 1
- brr(i, 1) = T
- brr(i, 2) = d(T)(0)
- End If
- Next
- Sheet1.[A7].Resize(d.Count, 2) = brr
- End If
- d.RemoveAll
- '问题二
- For i = 2 To UBound(arr)
- If 0 < InStr(arr(i, 5), "胃肠减压") Then
- T = arr(i, 1) & "|" & arr(i, 4)
- If Not d.exists(T) Then
- d(T) = Array(1, arr(i, 9))
- Else
- d(T) = Array(d(T)(0) + 1, d(T)(1) + arr(i, 9))
- End If
- End If
- Next
- ReDim brr(1 To d.Count, 1 To 2)
- i = 0
- If d.Count > 0 Then
- For Each T In d.keys
- If d(T)(0) > 1 Then
- i = i + 1
- brr(i, 1) = Split(T, "|")(0)
- brr(i, 2) = d(T)(1)
- End If
- Next
- Sheet1.[d7].Resize(d.Count, 2) = brr
- End If
- d.RemoveAll
- '问题三
- For i = 2 To UBound(arr)
- If 0 < InStr(arr(i, 5), "二级医院普通床位费") And arr(i, 7) > 40 Then
- T = arr(i, 1) & " " & arr(i, 4)
- If Not d.exists(T) Then
- d(T) = Array(1, arr(i, 9))
- Else
- d(T) = Array(d(T)(0) + 1, d(T)(1) + arr(i, 9))
- End If
- End If
- Next
- ReDim brr(1 To d.Count, 1 To 2)
- i = 0
- If d.Count > 0 Then
- For Each T In d.keys
- If d(T)(0) > 1 Then
- i = i + 1
- brr(i, 1) = T 'Split(T, " ")(0)
- brr(i, 2) = d(T)(1)
- End If
- Next
- Sheet1.[G7].Resize(d.Count, 2) = brr
- End If
- d.RemoveAll
- '问题四
- Dim tian As Integer
- For i = 2 To UBound(arr)
- T = arr(i, 1)
- If Not d.exists(T) Then
- tian = arr(i, 3) - arr(i, 2)
- d(T) = Array(1, arr(i, 9), tian)
- Else
- d(T) = Array(d(T)(0) + 1, d(T)(1) + arr(i, 9), d(T)(2))
- End If
- Next
- ReDim brr(1 To d.Count, 1 To 2)
- i = 0
- If d.Count > 0 Then
- For Each T In d.keys
- If d(T)(0) > d(T)(2) Then
- i = i + 1
- brr(i, 1) = T
- brr(i, 2) = d(T)(1)
- End If
- Next
- Sheet1.[J7].Resize(d.Count, 2) = brr
- End If
- End Sub
复制代码
|
|