Sub PerformCleanup()
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Global = True
objRegEx.Pattern = "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"
numRows = Sheets("Sheet1").Range("A50000").End(xlUp).Row
For i = numRows To 1 Step -1
' delete incomplete rows
If Range("A" & i).Value = "" Or Range("A" & i).Value = "" Or Range("A" & i).Value = "" Then
Rows(i & ":" & i).Select
Selection.Delete Shift:=xlUp
End If
' Remove spaces in customer name
Range("A" & i).Replace " ", ""
' Find and
strSearchString = Range("C" & i).Value
Set colMatches = objRegEx.Execute(strSearchString)
Range("C" & i).ClearContents
If colMatches.Count > 0 Then
For Each strMatch In colMatches
Range("C" & i).Value = Range("C" & i).Value & strMatch.Value & " "
Next
Range("C" & i).Value = Left(Range("C" & i).Value, Len(Range("C" & i).Value) - 1)
End If
Next i
Set objFSO = Nothing
Set objFile = Nothing
End Sub
|