- Sub test0() '假定 蓝区 与 绿区 标题一致 且 姓名排序一致
-
- Dim ar(1), br(), cr
- Dim i As Long, j As Long, r As Long, c As Long
-
- c = 6
- With Sheet1
- For j = 0 To UBound(ar)
- ar(j) = .Cells(1, 1 + j * 11).CurrentRegion.Offset(, 1).Resize(, 6).Value
- Next
- End With
- ReDim br(1 To UBound(ar(0)) * 5, 1 To c)
- cr = Split("估分 实考 差值")
-
- For i = 2 To UBound(ar(0))
- r = r + 1
- br(r, 1) = ar(0)(i, 1)
- For j = 2 To UBound(br, 2)
- br(r, j) = ar(0)(1, j)
- Next
- r = r + 1
- For j = 0 To 2
- br(r + j, 1) = cr(j)
- If j < 2 Then
- For c = 2 To UBound(br, 2)
- br(r + j, c) = ar(j)(i, c)
- br(r + 2, c) = br(r + 1, c) - br(r, c)
- Next
- End If
- Next
- r = r + j
- Next
-
- With Sheet2
- .UsedRange.Clear
- With .Range("A1").Resize(r - 1, UBound(br, 2))
- .Borders.LineStyle = xlContinuous
- .HorizontalAlignment = xlCenter
- .Value = br
- End With
- End With
-
- Beep
- End Sub
复制代码 |