VBAソリューションを気にしない場合は、最初のものを除くすべての重複IDの隣に「重複」が表示されます。
=RANDBETWEEN(1, 1000)
を使用して作成した35,000の数値IDでテストしたところ、671msで実行されました。範囲を配列に渡すと、より速く実行されます。
'Remove line to remove timing.
Private Declare Function GetTickCount Lib "kernel32"() As Long
'Will not mark first occurrence as duplicate.
Public Sub CheckForDuplicates()
Dim rng As Range
Dim rCell As Range
Dim dict As Object
'Remove next two lines to remove timing.
Dim TC As Long
TC = GetTickCount
'Update sheet name as required.
With ThisWorkbook.Worksheets("Sheet1")
'Defines range as A2 to last row containing data (providing there's no empty cells in col A).
'-1 at end of line as we're starting on row 2.
Set rng = .Range("A2").Resize(.Cells(Rows.Count, 1).End(xlUp).Row - 1)
End With
Set dict = CreateObject("Scripting.Dictionary")
With dict
For Each rCell In rng
If .Exists(rCell.Value) Then
rCell.Offset(, 1) = "Duplicate"
Else
.Add rCell.Value, rCell.Value
End If
Next rCell
End With
'Remove line to remove timing.
MsgBox GetTickCount - TC & "ms elapsed."
End Sub
これは**ワンタイム**の必要性ですか? – FDavidov
いいえ、毎週のことです。 – aSystemOverload
1つのオプションは、すべての行をIDでソートし、セルC3に式 '= IF(A2 = A3、" Duplicate "、" ")を展開し、数式をリストの最後までコピーし、列Cの「重複」の数を数えます。ただし、これは毎週繰り返す必要があります。 – FDavidov