本帖最后由 cutecpu 于 2021-1-15 14:26 编辑
Sub demo()
Sheets("表1").Select: arr = Range("A1").CurrentRegion
Sheets("表2").Select: Range("A1").CurrentRegion.Clear
Columns("A:H").Select: Selection.NumberFormatLocal = "@"
For i = 2 To UBound(arr, 1)
If arr(i, 1) <> class Then
class = arr(i, 1)
r = r + 2
Cells(r, 1).Value = arr(i, 1)
r = r + 1
Cells(r, 1).Value = "班主任": Cells(r, 2).Value = arr(i, 6)
Cells(r + 1, 1).Value = "运动员"
End If
If arr(i, 5) <> gender Then
gender = arr(i, 5)
r = r + 2: c = 1
Cells(r, 1).Value = arr(i, 5)
End If
If c = 8 Then c = 1: r = r + 2
c = c + 1
Cells(r, c).Value = arr(i, 2)
Cells(r + 1, c).Value = arr(i, 3)
Next
Range("A2").Select
End Sub
祝順心,南無阿彌陀佛!