|
- Sub qs()
- Application.ScreenUpdating = False
- Dim arr, i, xb As Workbook, p, rng As Range
- p = ThisWorkbook.Path & "\在校生导出.xlsx"
- Set xb = Workbooks.Open(p, 0)
- arr = xb.Sheets("在校学生列表").UsedRange.Value
- xb.Close (0)
- With Sheet2
- .Range("B7:B10,D7:D10,F7:F10,H7:H10,J7:J10,B14:B17,D14:D17,F14:F17,H14:H17,J14:J17").ClearContents
- Set rng = .Rows("3:18")
- col = 0: rw = 7
- For i = 2 To UBound(arr)
- If arr(i, 3) <> Empty Then
- col = col + 2
- If col > 10 Then
- col = 2
- rw = rw + 7
- End If
- If rw > 14 Then
- col = 2: rw = 7
- r = .Cells(Rows.Count, 1).End(3).Row + 1
- rng.Copy .Range("a" & r)
- .Range("B7:B10,D7:D10,F7:F10,H7:H10,J7:J10,B14:B17,D14:D17,F14:F17,H14:H17,J14:J17").ClearContents
- Application.CutCopyMode = False
- End If
- .Cells(rw, col) = arr(i, 1): .Cells(rw + 1, col) = arr(i, 2)
- .Cells(rw + 2, col) = "'" & arr(i, 4): .Cells(rw + 3, col) = "'" & arr(i, 3)
- End If
- Next
- End With
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|