2012-07-26 31 views
1

我在(Sheet4)列的数据给我:检查是否有行是重复和强调

我想对所有行(仅在列A和B)的数据进行比较,看看是否有任何行重复,如果是:excel应该突出显示两行。 实施例:

 
A B C......I 

s 1 x 

s 3 w 

e 5 q 

s 1 o 

行1和4,应强调指出,值是A列中相同和B.

我不应该修改片材(不修改列或行应做到表格),并且行数不总是已知的(对于所有文件都不相同)。

有没有简单的方法(使用宏)来做到这一点?

这是我尝试过的一种尝试,但它将我的文件增加到7MB !!!!!我敢肯定,如果存在的话,应该是比较行未知的行数,只是突出dupllicates更简单的方法:

Public Sub duplicate() 
    Dim errorsCount As Integer 
    Dim lastrow As Integer 
    Dim lastrow10 As Integer 
    errorsCount = 0 

    lastrow = Sheet4.Cells(Rows.Count, "A").End(xlUp).Row 'is the row number of the last non-blank cell in the specified column 
    lastrow10 = lastrow 
    Sheet10.Range("B1:B" & lastrow10).Value = Sheet4.Range("A1:A" & lastrow).Value 
    Set compareRange = Sheet10.Range(column + "2:" & Sheet10.Range(column + "2").End(xlDown).Address) 
    For Each a In Sheet10.Range(column + "2:" & Sheet10.Range(column + "2").End(xlDown).Address) 
     c = a.Value 
     If c <> Null Or c <> "" Then 
      If name = "testing" Then 
         If WorksheetFunction.CountIf(compareRange, c) > 1 Then 
         a.Interior.ColorIndex = 3 
         errorsCount = errorsCount + 1 
         End If 
      End If 
     End If 
    Next a 

    If errorsCount > 0 Then 
     MsgBox "Found " + CStr(errorsCount) + " errors" 
    Else 
     MsgBox " No errors found." 
    End If 
End Sub 

回答

2

傻回答你。

J1或只是复制工作表。 J1 = CONCATENATE(A1,“#”,B1)>向下拖拽> J:J>条件格式>突出显示单元格规则>重复值。

(*替换#到你认为不可能的原稿中的任意字符串:A和B:B)

我做这一切的时候。

收集所有重复只是颜色排序。

+0

+ 1.不,它不傻:) – 2012-07-26 13:34:57

+0

谢谢user1543250 我试图做这个使用宏,但thanx为您的答案 – Mash 2012-07-29 05:45:12