I'm looking for some guidance with a task I have been set from my eager new boss!
I've got a list of error codes in a named range "List", and a list of specific error codes that need to be identified "Codes".
What I need is some VBA code that will will check "List" and if any code exists that isn't in the "Codes" list it will delete it. (So, if it's in the "codes" range it stays, otherwise it gets deleted).
Can anybody help me with this please?
So far I've got this code, but it only does the opposite and deletes the codes I want to keep!
Sub DeleteCodes()
Application.ScreenUpdating = False
Dim InRange As Range, CritRange As Range
Dim InCell As Range, CritCell As Range
Set InRange = Range("Data") ' all selected source cells
Set CritRange = Range("List") ' the named range of words to be excluded
For Each InCell In InRange.Cells
For Each CritCell In CritRange.Cells
If InCell = CritCell Then
InCell = "" ' blank it
Exit For ' exit inner for
End If
Next CritCell
Next InCell
Application.ScreenUpdating = True
End Sub