Or with slightly better names (no typos!)
Sub repeated()
Dim i, j, k As Integer
k = 1
i = 1
Do Until Cells(i, 1) = ""
j = 1
Do Until Cells(j, 1) = "" Or (Cells(j, 1) = Cells(i, 1) And j <> i)
j = j + 1
Loop
If Cells(j, 1) = Cells(i, 1) Then
Cells(k, 2) = Cells(i, 1)
k = k + 1
End If
i = i + 1
Loop
End Sub
Sub notrepeated()
Dim i, j, k As Integer
k = 1
i = 1
Do Until Cells(i, 1) = ""
j = 1
Do Until Cells(j, 1) = "" Or (Cells(j, 1) = Cells(i, 1) And j <> i)
j = j + 1
Loop
If Cells(j, 1) <> Cells(i, 1) Then
Cells(k, 2) = Cells(i, 1)
k = k + 1
End If
i = i + 1
Loop
End Sub
Main Topics
Browse All Topics





by: stephenbarrowPosted on 2007-09-26 at 20:27:21ID: 19968626
Hi Use code like this:
Sub reperated()
Dim i, j, k As Integer
k = 1
i = 1
Do Until Cells(i, 1) = ""
j = 1
Do Until Cells(j, 1) = "" Or (Cells(j, 1) = Cells(i, 1) And j <> i)
j = j + 1
Loop
If Cells(j, 1) = Cells(i, 1) Then
Cells(k, 2) = Cells(i, 1)
k = k + 1
End If
i = i + 1
Loop
End Sub
Sub notrepested()
Dim i, j, k As Integer
k = 1
i = 1
Do Until Cells(i, 1) = ""
j = 1
Do Until Cells(j, 1) = "" Or (Cells(j, 1) = Cells(i, 1) And j <> i)
j = j + 1
Loop
If Cells(j, 1) <> Cells(i, 1) Then
Cells(k, 2) = Cells(i, 1)
k = k + 1
End If
i = i + 1
Loop
End Sub
regards,
Stephen