Forum Discussion
statejj16
Feb 12, 2022Copper Contributor
Find and Replace ### ### with just ###
What I am looking at is a column consisting of numbers with seven characters (###_L##, where "L" is a letter, # is a number, and "_" is just a space). However, there are sometimes numbers that are (#...
JMB17
Feb 13, 2022Bronze Contributor
If you are okay with a vba suggestion, you could try this (change the range reference to whatever your actual range is). And, be sure to back up your data before trying to ensure it's what you're looking for.
Sub test()
Dim cell As Range
With CreateObject("VbScript.RegExp")
.Pattern = "(\d{3}) \1"
For Each cell In Range("A1:A100")
If .test(cell.Value) Then
cell.Value = .Replace(cell.Value, "$1")
End If
Next cell
End With
End Sub