EXCEL高手请进,求VBA代码,解决难题~~~~

我B列都是数字,现在我要一段代码,执行之后,把B(X)=5 , B(X+1)=8 , B(X+2)=12 把满足条件的三行标记颜色

Sub fdas()
Dim n%, i%, rng As Range
n = Range("B65536").End(3).Row
For i = 1 To n
If Cells(i, 2) = 5 And Cells(i + 1, 2) = 8 And Cells(i + 2, 2) = 12 Then
If rng Is Nothing Then
Set rng = Range(Cells(i, 2), Cells(i + 2, 2))
Else
Set rng = Union(rng, Range(Cells(i, 2), Cells(i + 2, 2)))
End If
i = i + 2
End If
Next
rng.Interior.ColorIndex = 3
End Sub
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-04-18
Sub aa()
Application.ScreenUpdating = False
For i = 1 To Range("b65536").End(3).Row - 2
If Cells(i, 2) = 5 And Cells(i + 1, 2) = 8 And Cells(i + 2, 2) = 12 Then
Cells(i, 2).Resize(3, 1).Font.ColorIndex = 3
End If
Next
Application.ScreenUpdating = True
End Sub

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网