|
- Sub test()
- Dim r%, i%
- Dim arr, brr(1 To 1000, 1 To 8)
- Dim wb As Workbook
- Dim ws As Worksheet
- Dim mypath$, myname$
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- mypath = ThisWorkbook.Path & "\16科期考成绩"
- myname = Dir(mypath & "*.xlsx")
- m = 0
- Do While myname <> ""
- If myname <> ThisWorkbook.Name Then
- xm = Left(myname, 2)
- m = m + 1
- brr(m, 1) = xm
- Set wb = GetObject(mypath & myname)
- With wb
- With .Worksheets(1)
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- If r > 1 Then
- arr = .Range("a2:f" & r)
- For i = 1 To UBound(arr)
- If Len(arr(i, 6)) <> 0 Then
- brr(m, 2) = brr(m, 2) + 1
- brr(m, 3) = brr(m, 3) + arr(i, 6)
- If arr(i, 6) >= 60 Then
- brr(m, 4) = brr(m, 4) + 1
- End If
- If arr(i, 6) >= 80 Then
- brr(m, 6) = brr(m, 6) + 1
- End If
- End If
- Next
- End If
- End With
- .Close False
- End With
- End If
- myname = Dir
- Loop
- If m = 0 Then
- MsgBox "没有符合条件数据!"
- Exit Sub
- End If
- For i = 1 To m
- brr(i, 8) = InStr("一二三四五六", Left(brr(i, 1), 1)) * 10 + InStr("语数英", Right(brr(i, 1), 1))
- If Len(brr(i, 2)) <> 0 And brr(i, 2) <> 0 Then
- brr(i, 3) = Round(brr(m, 3) / brr(i, 2), 2)
- brr(i, 5) = Round(brr(i, 4) / brr(i, 2), 4)
- brr(i, 7) = Round(brr(i, 6) / brr(i, 2), 4)
- End If
- Next
- With Worksheets("三率统计表")
- .UsedRange.Offset(2, 0).Clear
- .Range("e:e,g:g").NumberFormatLocal = "0.00%"
- .Range("a3").Resize(m, UBound(brr, 2)) = brr
- .Range("a3").Resize(m, UBound(brr, 2)).Sort key1:=.Range("h3"), order1:=xlAscending, Header:=xlNo
- .Columns(8).Clear
- With .Range("a1")
- With .Font
- .Name = "微软雅黑"
- .Size = 18
- End With
- End With
- With .Range("a2").Resize(1 + m, 7)
- .Borders.LineStyle = xlContinuous
- With .Font
- .Name = "微软雅黑"
- .Size = 11
- End With
- End With
- .Rows(1).RowHeight = 30
- .Rows(2).Resize(1 + m).RowHeight = 20
- With .UsedRange
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|