Sub test00()
Dim arr(), arr0()
Dim i&, k&
'重写数组
arr = Sheet1.Range("a1").CurrentRegion
ReDim arr0(1 To UBound(arr), 1 To 5) '
'判断
k = 1
For i = 2 To UBound(arr)
'语文
If (arr(i, 4)) < 72 Then
arr0(k, 1) = arr(i, 1)
arr0(k, 2) = arr(i, 2)
arr0(k, 3) = arr(i, 3)
arr0(k, 4) = "语文"
arr0(k, 5) = arr(i, 4)
k = k + 1
'数学
ElseIf (arr(i, 5)) < 72 Then
arr0(k, 1) = arr(i, 1)
arr0(k, 2) = arr(i, 2)
arr0(k, 3) = arr(i, 3)
arr0(k, 4) = "数学"
arr0(k, 5) = arr(i, 5)
k = k + 1
'英语
ElseIf (arr(i, 6)) < 72 Then
arr0(k, 1) = arr(i, 1)
arr0(k, 2) = arr(i, 2)
arr0(k, 3) = arr(i, 3)
arr0(k, 4) = "英语"
arr0(k, 5) = arr(i, 6)
k = k + 1
'物理
ElseIf (arr(i, 7)) < 48 Then
arr0(k, 1) = arr(i, 1)
arr0(k, 2) = arr(i, 2)
arr0(k, 3) = arr(i, 3)
arr0(k, 4) = "物理"
arr0(k, 5) = arr(i, 7)
k = k + 1
'化学
ElseIf (arr(i, 8)) < 42 Then
arr0(k, 1) = arr(i, 1)
arr0(k, 2) = arr(i, 2)
arr0(k, 3) = arr(i, 3)
arr0(k, 4) = "化学"
arr0(k, 5) = arr(i, 8)
k = k + 1
'政治
ElseIf (arr(i, 9)) < 48 Then
arr0(k, 1) = arr(i, 1)
arr0(k, 2) = arr(i, 2)
arr0(k, 3) = arr(i, 3)
arr0(k, 4) = "政治"
arr0(k, 5) = arr(i, 9)
k = k + 1
'历史
ElseIf (arr(i, 10)) < 48 Then
arr0(k, 1) = arr(i, 1)
arr0(k, 2) = arr(i, 2)
arr0(k, 3) = arr(i, 3)
arr0(k, 4) = "历史"
arr0(k, 5) = arr(i, 10)
k = k + 1
End If
Next
'写入
For i = 1 To UBound(arr0)
With Sheet2
If Not IsEmpty(arr0(i, 1)) Then
.Cells(i + 1, 1) = arr0(i, 1)
.Cells(i + 1, 2) = arr0(i, 2)
.Cells(i + 1, 3) = arr0(i, 3)
.Cells(i + 1, 4) = arr0(i, 4)
.Cells(i + 1, 5) = arr0(i, 5)
End If
End With
Next
End Sub
|