|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
排序
Sub 汇总()
Dim ar As Variant
Dim br()
ReDim br(1 To 100000, 1 To 2)
For Each sh In Sheets
If IsNumeric(sh.Name) Then
ar = sh.UsedRange
For j = 11 To UBound(ar, 2) Step 4
For i = 2 To UBound(ar)
If Trim(ar(i, j)) <> "" Then
If IsNumeric(ar(i, j)) Then
n = n + 1
br(n, 1) = ar(i - 1, j)
br(n, 2) = ar(i, j)
End If
End If
Next i
Next j
End If
Next sh
If n = "" Then MsgBox "没有需要汇总的数据!": End
rr = Array("均", "标", "和")
With Sheets("汇总")
.UsedRange.Offset(2) = Empty
h = 1
For s = 0 To UBound(rr)
m = 0
ReDim cr(1 To n, 1 To 2)
For i = 1 To n
If InStr(br(i, 1), rr(s)) > 0 Then
m = m + 1
cr(m, 1) = br(i, 1)
cr(m, 2) = br(i, 2)
End If
Next i
If m > 0 Then
For i = 1 To m
For ss = i + 1 To m
If cr(i, 2) > cr(ss, 2) Then
For j = 1 To 2
k = cr(i, j)
cr(i, j) = cr(ss, j)
cr(ss, j) = k
Next j
End If
Next ss
Next i
.Cells(3, h).Resize(m, 2) = cr
End If
h = h + 4
Next s
End With
MsgBox "ok!"
End Sub
|
评分
-
1
查看全部评分
-
|