|
Sub 习题1()
Dim i As Integer
For i = 1 To Range("a65536").End(xlUp).Row
If Cells(i, 1) & Cells(i, 2) & Cells(i, 3) = Cells(i, 5) & Cells(i, 6) & Cells(i, 7) Then
Cells(i, 5).Interior.ColorIndex = 33
Cells(i, 5).Interior.Pattern = xlSolid
Cells(i, 5).Font.ColorIndex = 3
Cells(i, 6).Interior.ColorIndex = 33
Cells(i, 6).Interior.Pattern = xlSolid
Cells(i, 6).Font.ColorIndex = 3
Cells(i, 7).Interior.ColorIndex = 33
Cells(i, 7).Interior.Pattern = xlSolid
Cells(i, 7).Font.ColorIndex = 3
Else
Cells(i, 5).Interior.Pattern = xlNone
Cells(i, 5).Font.ColorIndex = 1
Cells(i, 6).Interior.Pattern = xlNone
Cells(i, 6).Font.ColorIndex = 1
Cells(i, 7).Interior.Pattern = xlNone
Cells(i, 7).Font.ColorIndex = 1
End If
Next
End Sub
应该增加类似 出现不满足条件的情况的设定。
(上文代码不要直接复制)
此外这种处理方式感觉代码运行时间比较长,诚请看到的大神介绍更加优化的方式
|
|