|
楼主 |
发表于 2016-10-7 22:45
|
显示全部楼层
本帖最后由 laoau138 于 2016-10-7 22:46 编辑
还有什么好方法,请发贴,高手
Sub 按钮1_Click()
With [a3:t12]
.ClearFormats
For i = 1 To .Columns.Count
For j = 1 To .Rows.Count
If .Cells(j, i) <> "" Then .Cells(j, i).Interior.Color = vbGreen
Next
Next
For i = 1 To .Columns.Count
For j = 1 To .Rows.Count
If .Cells(j, i) <> "" Then
If .Cells(j - 1, i) = "" Then
x = 1
While .Cells(j, i).Offset(x, 0) <> ""
x = x + 1
Wend
If x >= 5 Then
.Cells(j, i).Resize(x).Interior.Color = vbRed
ElseIf x = 4 Then
.Cells(j, i).Resize(x).Interior.Color = vbYellow
End If
End If
If i = 1 Then
GoTo xxx
ElseIf .Cells(j + 1, i - 1) = "" Then
xxx:
x = 1
While .Cells(j, i).Offset(-x, x) <> ""
x = x + 1
Wend
c = IIf(x >= 5, vbRed, vbYellow)
If x >= 4 Then
For k = 0 To x - 1
.Cells(j, i).Offset(-k, k).Interior.Color = c
Next
End If
End If
End If
Next
Next
End With
End Sub
|
评分
-
查看全部评分
|