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
+ 1.不,它不傻:) – 2012-07-26 13:34:57
謝謝user1543250 我試圖做這個使用宏,但thanx爲您的答案 – Mash 2012-07-29 05:45:12