代码仅供参考
- Sub 测试()
- Dim i%, j%, k%, m%, n%, arr, brr, sht As Worksheet
- arr = Sheet1.Range("A1").CurrentRegion
- brr = Sheet2.Range("A1").CurrentRegion
- Dim 科目, 分数线
- For j = 2 To UBound(arr, 2)
- 科目 = Left(arr(1, j), 2)
- 分数线 = arr(2, j)
- k = 0
- For m = 5 To 22 Step 2
- If brr(1, m) = 科目 Then
- ReDim crr(1 To 1000, 1 To 4)
- crr(1, 1) = "班级": crr(1, 2) = "姓名": crr(1, 3) = 科目: crr(1, 4) = "校次"
- For i = 2 To UBound(brr)
- If brr(i, m) >= 分数线 Then
- k = k + 1
- crr(k + 1, 1) = brr(i, 1)
- crr(k + 1, 2) = brr(i, 2)
- crr(k + 1, 3) = brr(i, m)
- crr(k + 1, 4) = brr(i, m + 1)
- End If
- Next
- End If
- Next
- For Each sht In ThisWorkbook.Worksheets
- If sht.Name = 科目 Then
- sht.Range("A1").Resize(k + 1, 4) = crr
- End If
- Next
- Next
- End Sub
复制代码 |