|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
问题不难,就是繁。
- Sub ykcbf() '//2024.8.21
- Set d = CreateObject("Scripting.Dictionary")
- arr = Sheets("人员表").UsedRange
- ReDim brr(1 To UBound(arr), 1 To UBound(arr, 2))
- ReDim crr(1 To UBound(arr), 1 To UBound(arr, 2))
- ReDim zrr(1 To 6)
- For i = 4 To UBound(arr)
- If arr(i, 1) <> Empty Then
- Select Case arr(i, 1)
- Case Is = "在职"
- m = m + 1
- For j = 1 To UBound(arr, 2)
- brr(m, j) = arr(i, j)
- Next
- Case Is = "离职"
- n = n + 1
- For j = 1 To UBound(arr, 2)
- crr(n, j) = arr(i, j)
- Next
- End Select
- s = arr(i, 5)
- d(s) = d(s) + 1
- s = arr(i, 6)
- d(s) = d(s) + 1
- zrr(1) = zrr(1) + IIf(arr(i, 13) <= 30, 1, 0)
- zrr(2) = zrr(2) + IIf((arr(i, 13) > 30 And arr(i, 13) <= 40), 1, 0)
- zrr(3) = zrr(3) + IIf((arr(i, 13) > 40 And arr(i, 13) <= 50), 1, 0)
- zrr(4) = zrr(4) + IIf((arr(i, 13) > 50 And arr(i, 13) <= 60), 1, 0)
- zrr(5) = zrr(5) + IIf((arr(i, 13) > 60 And arr(i, 13) <= 70), 1, 0)
- zrr(6) = zrr(6) + IIf(arr(i, 13) > 70, 1, 0)
- End If
- Next
- With Sheets("在职表")
- .UsedRange.Offset(3).ClearContents
- .[a4].Resize(m, UBound(arr, 2)) = brr
- End With
- With Sheets("离职表")
- .UsedRange.Offset(3).ClearContents
- .[a4].Resize(n, UBound(arr, 2)) = crr
- End With
- With Sheets("在职人员汇总")
- Sum = 0
- For i = 3 To 4
- s = .Cells(i, 1).Value
- .Cells(i, 2) = d(s)
- Sum = Sum + .Cells(i, 2).Value
- Next
- .Cells(5, 2) = Sum
- .Range("C:C,l:L").NumberFormatLocal = "0.00%"
- For i = 3 To 4
- .Cells(i, 3) = .Cells(i, 2).Value / Sum
- Next
- Sum = 0: m = 0
- For i = 11 To 16
- m = m + 1
- .Cells(i, 2) = zrr(m)
- Sum = Sum + .Cells(i, 2).Value
- Next
- .Cells(17, 2) = Sum
- .Columns(3).NumberFormatLocal = "0.00%"
- For i = 11 To 16
- .Cells(i, 3) = .Cells(i, 2).Value / Sum
- Next
- Sum = 0
- For i = 3 To 30
- s = .Cells(i, "j").Value
- .Cells(i, "k") = d(s)
- Sum = Sum + .Cells(i, "k").Value
- Next
- .Cells(31, "k") = Sum
- .Columns(3).NumberFormatLocal = "0.00%"
- For i = 3 To 30
- .Cells(i, 12) = .Cells(i, 11).Value / Sum
- Next
- End With
- MsgBox "OK!"
- End Sub
复制代码
|
|