目的:将汇总数据分类
代码实现:
Sub 分类() '将成绩表根据班级分到各个工作表中
Dim i As Long, bj As String, rng As Range
i = 3
bj = Cells(i, "B").Value
Do While bj <> "" '定义循环条件
'将分表中A列第一个单元格赋给rng
Set rng = Worksheets(Cells(i, "B").Value).Range("A65536").End(xlUp).Offset(1, 0)
Cells(i, "A").Resize(1, 4).Copy rng '将第1-4列数据记录复制到相应的工作表中
i = i + 1
bj = Cells(i, "B").Value
Loop
End Sub