|
代码如下。。。
Sub test()
Dim wb As Workbook, sht As Worksheet
Set wb = ThisWorkbook
Set sht = wb.Sheets("sheet1")
r = sht.Cells(Rows.Count, 2).End(3).Row
arr = sht.Range(sht.[b2], Cells(r, "g"))
ReDim brr(1 To 10000, 1 To 3)
For i = 2 To UBound(arr)
s = arr(i, 1)
For j = 2 To UBound(arr, 2)
f = 0
Set Rng = sht.Cells(i + 1, j + 1)
For k = 1 To Len(Rng.Value)
If Rng.Characters(k, 1).Font.ColorIndex = 3 Then f = 1: Exit For
Next
ss = arr(1, j)
n = n + 1
brr(n, 1) = s
brr(n, 2) = ss
If n > 5 Then
If f = 1 Then
brr(n, 3) = brr(n - 5, 3) + 1
Else
brr(n, 3) = brr(n - 5, 3) + 0
End If
Else
If f = 1 Then
brr(n, 3) = 1
Else
brr(n, 3) = 0
End If
End If
Next
Next
Application.DisplayAlerts = False
Application.ScreenUpdating = False
With sht
.[u3].CurrentRegion.Clear
.[u3].Resize(n, 3) = brr
.[u3].CurrentRegion.Borders.LineStyle = 1
.[u3].CurrentRegion.HorizontalAlignment = xlCenter
For i = n To 1 Step -1
If .Cells(i + 2, "u") = .Cells(i + 1, "u") Then .Cells(i + 1, "u").Resize(2).Merge
Next
End With
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Beep
End Sub
|
评分
-
2
查看全部评分
-
|