Alpha Frogs's macro here helped me greatly; (in this scenario I have a list of invalid codes) it find and replaces cells that do match a list of cells (list of invalid codes). If I replace with nothing I'm essentially clearing the cells which is what I needed.
The information I'm dealing with here are 9 character long numerical codes; potentially alphanumeric in the future.
Now I have a "Master List" of valid codes and want to clear cells that do not match this list. I'm talking about exact matches not partial ones.
Related- i'm trying to be resource conscious; I can't get my head around how to create a loop i've read examples but getting nowhere; how to improve the above?
Rich (BB code):
Rich (BB code):
sub Substitutions()
Dim rngData As Range
Dim rngLookup As Range
Dim Lookup As Range
With Sheets("Sheet1")
Set rngData = .Range("A:B")
End With
With Sheets("Sheet1")
Set rngLookup = .Range("D1", .Range("D" & Rows.Count).End(xlUp))
End With
For Each Lookup In rngLookup
If Lookup.Value <> "" Then
rngData.Replace What:=Lookup.Value, _
Replacement:=Lookup.Offset(0, 1).Value, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False
End If
Next Lookup
End Sub
The information I'm dealing with here are 9 character long numerical codes; potentially alphanumeric in the future.
Now I have a "Master List" of valid codes and want to clear cells that do not match this list. I'm talking about exact matches not partial ones.
Related- i'm trying to be resource conscious; I can't get my head around how to create a loop i've read examples but getting nowhere; how to improve the above?