View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default Create list of duplicated numbers

I think that would take forever to run Mike. 10,000 X 10,000 loops. The
following modification has only 10,000 loops. I tested the time taken and it
makes no real difference with screenupdating and calculation turned off.

Sub marine()

Dim MyRange1 As Range
Dim MyRange2 As Range
Dim c As Range
Dim x As Double

x = 6
Set MyRange1 = Range("B6:B10000")
Set MyRange2 = Range("I6:I10000")
For Each c In MyRange1.Cells
If WorksheetFunction.CountIf(MyRange2, c.Value) 0 Then
Cells(x, "S") = c.Value
x = x + 1
End If
Next c

End Sub

--
Regards,

OssieMac


"Mike H" wrote:

Hi,

Probably not the most effecient but try this

Sub marine()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim MyRange1 As Range
Dim MyRange2 As Range
x = 6
Set MyRange1 = Range("B6:B10000")
Set MyRange2 = Range("I6:I10000")
For Each c In MyRange1.Cells
For Each d In MyRange2.Cells
If c.Value = d.Value Then
Cells(x, 19).Value = c.Value
x = x + 1
Exit For
End If
Next
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub

Mike

"J.W. Aldridge" wrote:

I have a string of data (numbers) starting in B6:B10000 and another
in
I6:I10000..

I need a code to search both strings and return any numbers that
appeared in both list. This list of duplicated numbers should start in
S6.