Dim m As Integer Dim n As Integer m = 0 n = 0 For Each r1 As Row In Tables("A").rows For Each r2 As Row In Tables("B").rows If r2("学校名称") = r1("学校名称") And r2("年级") = r1("年级") And r2("考试号") > 0 Then m = m + 1 If r2("学校名称") = r1("学校名称") And r2("年级") = r1("年级") And r2(r1("学科")) > 0 Then n = n + 1 End If End If Next r1("登分数") = n r1("学生数") = m m = 0 n = 0 Next