View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
STEVE BELL STEVE BELL is offline
external usenet poster
 
Posts: 692
Default Test for dups in Array

As a general case I like to test for dupes with
Countif(Range(A:A),cellvalue)
either as a formula in a cell, criteria in Conditional Formating,
restriction in Data Validation, or
in code.

--
steveB

Remove "AYN" from email to respond
"Perico" wrote in message
...
I need help on how do I test for duplicate values in an array, x()?

My code so far:

Sub finddups()
Dim mstrWks As Worksheet
Dim myRng As Range
Dim x(), i As Long, j As Long
Set mstrWks = Worksheets("Master")

With mstrWks
Set myRng = .Range("b28", .Cells(.Rows.Count, "B").End(xlUp))
End With

j = myRng.Rows.Count
i = 1
With myRng
For j = 1 To j
ReDim x(j)
x(j) = .Cells(i, 1) & .Cells(i, 2) & .Cells(i, 3) & .Cells(i, 7)
i = i + 1
Next j
End With
End Sub