本文介绍了比较两个文本单元格并在Excel工作表2010/2007的第三列中显示差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想比较两个包含文本并以某种颜色显示差异的单元格
I want to compare two cells which contains text and show the difference in some colour
Ex:Cell A:NTR is a great Leader.
Cell B:Ntr is a Great leader
推荐答案
使用VBA .....
Using VBA.....
Sub CompareInColor()
ActiveSheet.Range("C1").Value = ActiveSheet.Range("A1").Value
For i = 1 To Len(ActiveSheet.Range("A1").Value)
If (ActiveSheet.Range("A1").Characters(i, 1).Text <>
ActiveSheet.Range("B1").Characters(i, 1).Text) Then
ActiveSheet.Range("C1").Characters(i, 1).Font.Color = RGB(255, 0, 0)
Next i
End Sub
这仅比较A1和B1 ...如果您有很多行,则循环遍历您的行.另外,我假设A1和A2的长度相同,否则可能会产生超出范围的索引错误.
This compares A1 and B1 only... Loop through your rows if you have many of them. Also, I assumed that the length of A1 and A2 is the same, otherwise an out-of-range index error may evolve.
这篇关于比较两个文本单元格并在Excel工作表2010/2007的第三列中显示差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!