Sub cmdcount()
cows = Selection.Rows.Count
count1 = 0
count3 = 0
count0 = 0
For I = 1 To cows
If Selection.Cells(I, 1) = 1 Then count1 = count1 + 1
If Selection.Cells(I, 1) = 3 Then count3 = count3 + 1
If Selection.Cells(I, 1) = 0 Then count0 = count0 + 1
Next
countall = count1 + count0 + count3
For I = 1 To cows
Selection.Cells(I, 1).Next.Value = count3 / countall
Selection.Cells(I, 1).Next.Next.Value = count1 / countall
Selection.Cells(I, 1).Next.Next.Next.Value = count0 / countall
Next
End Sub
Sub autoac()
Set use = Range(Selection.Cells(1, 1), Selection.Cells _
(Selection.Rows.Count, 5))
CO = use.Rows.Count
SCO = 0
s1 = 0
S0 = 0
Set TE = Selection.Range(Cells(1, 1), Cells(1, 5))
For I = 1 To CO + 1
Y = NE(use.Cells(I, 1))
YY = NE(TE.Cells(TE.Rows.Count, 1))
If Y = YY Then
Set TE = Application.Union(TE, Range(use.Cells(I, 1), use.Cells(I, 5)))
Else
TEMP = SCO / TE.Rows.Count
TEMP1 = s1 / TE.Rows.Count
TEMP0 = S0 / TE.Rows.Count
For X = 1 To TE.Rows.Count
TE.Cells(X, 3) = TEMP
TE.Cells(X, 4) = TEMP1
TE.Cells(X, 5) = TEMP0
Next
Set TE = Range(use.Cells(I, 1), use.Cells(I, 5))
SCO = 0
S0 = 0
s1 = 0
End If
If use.Cells(I, 2) = 3 Then SCO = SCO + 1
If use.Cells(I, 2) = 1 Then s1 = s1 + 1
If use.Cells(I, 2) = 0 Then S0 = S0 + 1
Next
End Sub
Public Function NE(IT)
If IT = "" Then
NE = "NA"
Else
If Len(IT) < 5 Then S = IT & String(5 - Len(IT), "0") Else S = IT
SM = Right(S, 2)
SN = Left(SM, 1)
SF = IIf(Right(SM, 1) <= 4, 0, 1)
NE = SN & SF
End If
End Function