The below macro clears cells that do not match with the D column range. The issue is my required ranges are too large for the macro to run on my computer.
Sub REMOVEPIDS()Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.EnableEvents = False
Dim Rng As Range, Dn As Range
Set Rng = Range("D2:D35525") 'Range to match against
With CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
For Each Dn In Rng: .Item(Dn.Value) = Empty: Next
Set Rng = Range("F2:DVF62601") ' Range to clear
For Each Dn In Rng
If Not .exists(Dn.Value) Then Dn.ClearContents
Next Dn
End With
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Application.DisplayStatusBar = True
Application.EnableEvents = True
End Sub
Sub REMOVEPIDS()Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.EnableEvents = False
Dim Rng As Range, Dn As Range
Set Rng = Range("D2:D35525") 'Range to match against
With CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
For Each Dn In Rng: .Item(Dn.Value) = Empty: Next
Set Rng = Range("F2:DVF62601") ' Range to clear
For Each Dn In Rng
If Not .exists(Dn.Value) Then Dn.ClearContents
Next Dn
End With
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Application.DisplayStatusBar = True
Application.EnableEvents = True
End Sub
Last edited: