Originally Posted by
Paleo
I have no clue on how to make it faster.
Let me know how fast this code runs.
Option Explicit
Sub macro1()
Dim i As Long
Dim j As Long
Dim Texto As String
Dim LastRow As Long
Dim SearchRange As Range
Dim Cel As Range
Dim FirstAddress As String
Dim RngOK As Range
Dim RngAbove As Range
Dim RngUnder As Range
Dim RngTemp As Range
Application.ScreenUpdating = False
Application.EnableEvents = False
LastRow = Range("K65536").End(xlUp).Row
Set SearchRange = Sheets("Class 2").Range("A2:A" & _
Sheets("Class 2").Range("A65536").End(xlUp).Row)
'This needs to be an unused cell.
Set RngTemp = Range("Z1")
Set RngOK = RngTemp
Set RngAbove = RngTemp
Set RngUnder = RngTemp
For i = 1 To LastRow
Select Case Range("K" & i).Value
Case Is = 0
Set RngOK = Union(RngOK, Range("L" & i))
Case Is < 0
Set RngUnder = Union(RngUnder, Range("L" & i))
Case Else
Texto = Range("B" & i).Text & Range("D" & i).Text
With SearchRange
Set Cel = .Find(What:=Range("B" & i).Text, LookIn:=xlValues, _
LookAt:=xlWhole, MatchCase:=True)
If Not Cel Is Nothing Then
FirstAddress = Cel.Address
Do
If Cel.Offset(0, 1).Text = Range("D" & i).Text And _
Sheets("Class 2").Range("D" & Cel.Row) = 0 Then
Set RngAbove = Union(RngAbove, Range("L" & i))
Exit Do
End If
Set Cel = .FindNext(Cel)
Loop While Not Cel Is Nothing And Cel.Address <> FirstAddress
End If
End With
End Select
Next i
RngOK.Value = "Ok"
RngUnder.Value = "Under"
RngAbove.Value = "Above"
RngTemp.ClearContents
Set RngOK = Nothing
Set RngUnder = Nothing
Set RngAbove = Nothing
Set RngTemp = Nothing
Set SearchRange = Nothing
Set Cel = Nothing
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub