I loop through two sheets (OLD, NEW) to determine which values are non-existing in the other.
The values are not always in the same sequence, therefore I can't check row by row. I search to see if a value exists.
The following takes a long time to run. (01:50 min with my test ranges.)
Sub LOOPING()
'-------------------------------------------------------------------
Dim StartTime As Double
StartTime = Timer
'-------------------------------------------------------------------
Dim rngNEW As Range
Set rngNEW = Sheets("NEW").Range("D1:D6734")
Dim rngOLD As Range
Set rngOLD = Sheets("OLD").Range("D1:D6734")
a = ""
For Each item In rngNEW
For Each item2 In rngOLD
If item = item2 Then
GoTo NextIter
End If
Next item2
a = a & "," & item.Row
NextIter:
Next item
MsgBox a
'-------------------------------------------------------------------
MsgBox "RunTime : " & Format((Timer - StartTime) / 86400, "hh:mm:ss")
'-------------------------------------------------------------------
End Sub
The following runs fast but does not return anything (00:02 min with the same test ranges.)
I found the match function does not work with cell values greater than 255 characters. Some of the cell values exceed 3000 characters.
Sub MATCHING()
'-------------------------------------------------------------------
Dim StartTime As Double
StartTime = Timer
'-------------------------------------------------------------------
Dim rngNEW As Range
Set rngNEW = Sheets("NEW").Range("D1:D6734")
Dim rngOLD As Range
Set rngOLD = Sheets("OLD").Range("D1:D6734")
a = ""
For Each item In rngNEW
If IsError(Application.Match(item, rngOLD, 0)) Then
a = a & "," & item.Row
End If
Next item
MsgBox a
'-------------------------------------------------------------------
MsgBox "RunTime : " & Format((Timer - StartTime) / 86400, "hh:mm:ss")
'-------------------------------------------------------------------
End Sub
Is there a way to overcome the 255 character limit?