EXCEL高手请进,求VBA代码,解决难题~~~~
我B列都是数字,现在我要一段代码,执行之后,把B(X)=5,B(X+1)=8,B(X+2)=12把满足条件的三行标记颜色...
我B列都是数字,现在我要一段代码,执行之后,把B(X)=5 , B(X+1)=8 , B(X+2)=12 把满足条件的三行标记颜色
展开
2个回答
展开全部
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
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
展开全部
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
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询