|
楼主 |
发表于 2018-7-31 20:39
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
自己写了一段!
Sub 统计天数1()
Dim a%, b%, d%, e%, f%, g%, h%, i%, j%, k%
For x = 6 To 29 Step 2
a = 0
b = 0
c = 0
d = 0
e = 0
f = 0
g = 0
h = 0
i = 0
j = 0
k = 0
For y = 2 To 32 Step 1
If Cells(x, y) = "2" Then
a = a + 1
Else
If Cells(x, y) = "4" Then
b = b + 1
Else
If Cells(x, y) = "#" Then
c = c + 1
Else
If Cells(x, y) = "假" Then
d = d + 1
Else
If Cells(x, y) = "×" Then
e = e + 1
Else
If Cells(x, y) = "○" Then
f = f + 1
Else
If Cells(x, y) = "﹢" Then
g = g + 1
Else
If Cells(x, y) = "-" Then
i = i + 1
Else
If Cells(x, y) = "A" Then
h = h + 1
Else
If Cells(x, y) = "B" Then
j = j + 1
Else
If Cells(x, y) = "3" Then
k = k + 1
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
For z = 3 To 32 Step 1
If Cells(x, y) = Cells(x, z) And Cells(x, y).Value <> "" And Application.CountA(Range(Cells(x, y + 1), Cells(x, z - 1))) = 0 Then
If Cells(x, y) = "假" Then
d = d + z - y - 1
Else
If Cells(x, y) = "×" Then
e = e + z - y - 1
Else
If Cells(x, y) = "2" Then
a = a + z - y - 1
Else
If Cells(x, y) = "4" Then
b = b + z - y - 1
Else
If Cells(x, y) = "#" Then
c = c + z - y - 1
Else
If Cells(x, y) = "○" Then
f = f + z - y - 1
Else
If Cells(x, y) = "﹢" Then
g = g + z - y - 1
Else
If Cells(x, y) = "A" Then
h = h + z - y - 1
Else
If Cells(x, y) = "B" Then
j = j + z - y - 1
Else
If Cells(x, y) = "3" Then
k = k + z - y - 1
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
Next
Next
If a > 0 Then
Range("AK" & x) = Range("AK" & x) & "上班:" & a & "天;"
End If
If b > 0 Then
Range("AK" & x) = Range("AK" & x) & "四类区野外:" & b & "天;"
End If
If c > 0 Then
Range("AK" & x) = Range("AK" & x) & "出差:" & c & "天;"
End If
If d > 0 Then
Range("AK" & x) = Range("AK" & x) & "休假:" & d & "天;"
End If
If e > 0 Then
Range("AK" & x) = Range("AK" & x) & "旷工:" & e & "天;"
End If
If f > 0 Then
Range("AK" & x) = Range("AK" & x) & "事假:" & f & "天;"
End If
If g > 0 Then
Range("AK" & x) = Range("AK" & x) & "工伤:" & g & "天;"
End If
If h > 0 Then
Range("AK" & x) = Range("AK" & x) & "探亲:" & h & "天;"
End If
If i > 0 Then
Range("AK" & x) = Range("AK" & x) & "病假在工地:" & i & "天;"
End If
If j > 0 Then
Range("AK" & x) = Range("AK" & x) & "病假离工地:" & j & "天;"
End If
If k > 0 Then
Range("AK" & x) = Range("AK" & x) & "三类区野外:" & k & "天;"
End If
Next
End Sub |
|