Hello everyone,
I am hoping someone can help me find a solution that works faster than the current one I am using.
I have 2 sheets "LOF Summary" and "Car List - Assign."
Sheet 1 contains data in columns A to M.
Sheet 2 contains data only in column A.
I want a code that will check the data found in column A (range A4:A28) of Sheets("Car List - Assign.") with those in Column A (Range A7:A1000) of Sheets("LOF Summary").
If an exact match is NOT found in Column A of Sheets("LOF Summary"), Excel will only clear the contents of the row from Column A to Column H.
Here is the code I am using which does work but it takes around 30 or more seconds for it to process. I am hoping to find a faster or more efficient code.
I am hoping someone can help me find a solution that works faster than the current one I am using.
I have 2 sheets "LOF Summary" and "Car List - Assign."
Sheet 1 contains data in columns A to M.
Sheet 2 contains data only in column A.
I want a code that will check the data found in column A (range A4:A28) of Sheets("Car List - Assign.") with those in Column A (Range A7:A1000) of Sheets("LOF Summary").
If an exact match is NOT found in Column A of Sheets("LOF Summary"), Excel will only clear the contents of the row from Column A to Column H.
Here is the code I am using which does work but it takes around 30 or more seconds for it to process. I am hoping to find a faster or more efficient code.
VBA Code:
Sub test()
Dim LR As Long, i As Long
Application.ScreenUpdating = False
With Sheets("LOF Summary")
LR = .Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 6 Step -1
If IsError(Application.Match(.Range("A" & i).Value, Sheets("Car List - Assign.").Columns("A"), 0)) Then .Range("A" & i & ":H" & i).ClearContents
Next i
End With
Range("A7:H" & LR).Sort Key1:=Range("A7:H" & LR), Order1:=xlAscending, Header:=xlNo
Application.ScreenUpdating = True
End Sub