
Originally Posted by
sintek
...Evaluate on smaller datasets is generally much faster that formula to value conversion and loop...
Sorry, I know you're ready to move on, but it's not fair to directly contradict what I said in post#43 and not expect a response. I agree that EVALUATE is faster than looping in some cases, but if you're writing the array back to the sheet, it's NOT faster than formula-to-value conversion.
Here's two versions of your program (altered to fix sort). They both put a 1 in column J for matches, and "" for misses. The ONLY difference is, the first writes a formula to the sheet and converts it to values. The second EVALUATEs an array version of the same formula and writes the array to the sheet, as your original code did.
Sub sintek3_ALTERED_Formula2Sheet()
Application.ScreenUpdating = False
Dim a As String, b As String
b = "B!$E$2:" & Sheets("B").Cells(Rows.count, "E").End(xlUp).Address()
With Sheets("Check").Cells(1).CurrentRegion
With .Columns(.Columns.count + 1).Offset(1).Resize(.Rows.count - 1)
.Formula = "=IF(ISNUMBER(MATCH(I2," & b & ",0)),1,"""")"
.Value = .Value
.EntireRow.Resize(, .Column).Sort .Cells(1), xlAscending, , , , , , xlNo
.SpecialCells(xlCellTypeBlanks).EntireRow.Resize(, .Column).Delete
.Clear
End With
End With
Application.ScreenUpdating = True
'=IF(ISNUMBER(MATCH(I2,'B'!$E$2:$E$51,0)),1,"")
End Sub
Sub sintek3_ALTERED_Array2Sheet()
Application.ScreenUpdating = False
Dim a As String, b As String
b = "B!$E$2:" & Sheets("B").Cells(Rows.count, "E").End(xlUp).Address()
With Sheets("Check").Cells(1).CurrentRegion
With .Columns(.Columns.count + 1).Offset(1).Resize(.Rows.count - 1)
a = .EntireRow.Columns("I").Address(external:=True)
.Value = Evaluate("IF(ISNUMBER(MATCH(" & a & "," & b & ",0)),1,"""")")
.EntireRow.Resize(, .Column).Sort .Cells(1), xlAscending, , , , , , xlNo
.SpecialCells(xlCellTypeBlanks).EntireRow.Resize(, .Column).Delete
.Clear
End With
End With
Application.ScreenUpdating = True
'=IF(ISNUMBER(MATCH(Check!$I$2:$I$100001,B!$E$2:$E$51,0)),1,"")
End Sub
.CompareSub5.jpg
Bookmarks