The following VBA script gets rid of unwanted characters, but unfortunately only NUMBERS.
could you help me? You must also discard the letters, as in the example table below (bold).
The range can be from 0 to 15000+ cells
.................................................. ...
a new a york a times a
b new b york b times b
c new c york c watertown c ny c
6 ave 6 new 6 york 6 city 6
>
.................................................. ....
VBA script:
Sub Remove() Application.ScreenUpdating = False Dim R As RegExp, C As Range For Each C In Range("A1:A" & Cells(Rows.Count, 1).End(xlUp).Row) If R Is Nothing Then Set R = New RegExp R.Global = True R.Pattern = "\D" C.Offset(0, 1) = R.Replace(C, "") R.Pattern = "\d" C = R.Replace(C, "") End If Set R = Nothing Next C Application.ScreenUpdating = True End Sub
EDIT1
Sub Remove() Call BackMeUp Dim cell As Range Dim RE As Object Dim Whitecell As Range Dim strFind As String, strReplace As String Dim lLoop As Long Dim Loop1 As Long Application.ScreenUpdating = False Application.Calculation = xlCalculationManual Application.EnableEvents = False Range("A3:L3").Select Selection.Delete Shift:=xlUp '--------------------------------------------------Remove JUNK Range("A3:A" & Cells(Rows.Count, 1).End(xlUp).Row).Select On Error Resume Next For lLoop = 1 To 100 strFind = Choose(lLoop, "~?»", "~®", "~.", "~!", "~ï", "~-", "~§", "~$", "~%", "~&", "~/", "~\", "~,", "~(", "~)", "~=", "~www", "~WWW", "~.com", "~.net", "~.org", "~{", "~}", "~[", "~]", "~ï", "~¿", "~½", "~:", "~;", "~_", "~µ", " ~@ ", "~#", "~'", "~|", "~€", "~ä", "~ö", "~ü", "~Ä", "~Ü", "~Ö", "~+", "~<", "~>", "~nbsp", "~â", "~¦", "~©", "~Â", "~–", "~¼", "~?") strReplace = Choose(lLoop, " ") Selection.Replace What:=strFind, Replacement:=strReplace, LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Next lLoop '--------------------------------------------------Remove Numbers Range("A3:A" & Cells(Rows.Count, 1).End(xlUp).Row).Select On Error Resume Next For Loop1 = 1 To 40 strFind = Choose(lLoop, "~1", "~2", "~3", "~4", "~5", "~6", "~7", "~8", "~9", "~0") strReplace = Choose(Loop1, " ") Selection.Replace What:=strFind, Replacement:=strReplace, LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Next Loop1 '--------------------------------------------------Remove Single Letters Set RE = CreateObject("vbscript.regexp") RE.Global = True RE.MultiLine = True RE.Pattern = "^[az]\b | \b[az]\b" For Each cell In Range("A3:A" & Cells(Rows.Count, 1).End(xlUp).Row) cell.Value = RE.Replace(cell.Value, "") Next '--------------------------------------------------Remove WHITE SPACES For Each Whitecell In Range("A3:A" & Cells(Rows.Count, 1).End(xlUp).Row) Whitecell = WorksheetFunction.Trim(Whitecell) Next Whitecell '--------------------------------------------------Remove DUPES ActiveSheet.Range("A3:A" & Cells(Rows.Count, 1).End(xlUp).Row).RemoveDuplicates Columns:=1, Header:=xlYes ActiveWorkbook.Worksheets(ActiveSheet.Name).Sort.SortFields.Clear '--------------------------------------------------Copy to B - REPLACE ALL WHITE IN B Range("A3:A" & Cells(Rows.Count, 1).End(xlUp).Row).Select Selection.Copy Range("B3:B" & Cells(Rows.Count, 1).End(xlUp).Row).Select ActiveSheet.Paste Selection.Replace What:=" ", Replacement:="", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Columns("A:L").EntireColumn.AutoFit '--------------------------------------------------END Application.ScreenUpdating = True Application.Calculation = xlCalculationAutomatic Application.EnableEvents = True Range("a1").Select End Sub