【发布时间】:2019-03-17 14:19:42
【问题描述】:
我在标题Name List 1 和Name List 2 的工作表中有两列。
我想比较这两列并以红色突出显示 Name List 1 中不存在但存在于 Name list 2 中的名称,反之亦然。如果名称在两列中都相同,则将其保留为白色。
两个列表的列范围不一样。
Sub indicators()
lastrowlist1 = Range("C1000000").End(xlUp).Row
lastrowlist2 = Range("K1000000").End(xlUp).Row
For i = 5 To lastrowlist1
Range("C" & i).Value = findval
For j = 5 To lastrowlist2
If Range("K" & j).Value <> Range("C" & i).Value Then
Range("K" & j).Interior.ColorIndex = 4
Range("C" & i).Interior.ColorIndex = 4
Else
Range("K" & j).Interior.ColorIndex = 2
Range("C" & i).Interior.ColorIndex = 2
End If
Next j
Next i
End Sub
【问题讨论】:
-
使用条件格式,或者至少表明你的努力并告诉我们你的代码的哪一部分被卡住了
-
条件格式的问题是它会减慢excel工作簿的速度。