for i=1 to activesheet.usedrange.rows.count
x=trim(cells(i,1))
db(x)=db(x)+1
next i
i=1
for each x in db.keys
cells(i,3)=x
cells(i,4)=db(x)
i=i+1
next k
用鼠标选择一个区域,比如 a2:d10,然后运行代码Sub test2()
Dim Arr1, Arr2
Dim i, j, k As Integer
Arr1 = Application.Selection
If Arr1 = "" Then
MsgBox "Please select data"
Exit Sub
End If
k = UBound(Arr1)
ReDim Arr2(1 To k, 1 To 2)
For i = 1 To k
For j = 1 To 4
If Arr1(i, j) <6 Then
Arr2(i, 1) = Arr2(i, 1) + 1
Else
Arr2(i, 2) = Arr2(i, 2) + 1
End If
Next j
Next i
Columns("f:g").Clear
i = Application.Selection.Row
Range(Cells(i, 6), Cells(i + k - 1, 7)) = Arr2
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)