I have cells that look like this, one per line:
Duffy,John: \'Heritage: Civilization and the Jews\'- Fanfare & Chorale,Symphonic Dances + Orchestr
I was faced with a similar problem, but went another way, wanting to avoid using vba. A recursive use of substitute did the trick for me, as illustrated below:
Original data (in A1:An, n=integer) ROE -1.00 P/E 0.07 -0.85 ROC-ROE 0.02 -0.03 etc..
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"1",""),"0",""),"2",""),"3",""),"4",""),"5",""),"6",""),"7",""),"8",""),"9","")
which can be extended to get rid of "-" and the decimal indicator "." as well as "+" (if relevant) and finally, superfluous spaces using
=trim(substitute(substitute(substitue(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"1",""),"0",""),"2",""),"3",""),"4",""),"5",""),"6",""),"7",""),"8",""),"9",""),"-",""),"+","")," .",""))
where the lowercase represents complications added in the current step.
This maps naturally onto the entire array by changing the range reference to the entire array to be parsed (A1:An) and entering the formula as an array (i.e., using Ctl+Enter instead of Enter to complete the task).
I then use len(B1) to check the results are what I want.
Not elegant, admittedly. But may be a useful exercise for teaching students to think and code "on the fly."
UPDATED: I had accidentally posted a contains function instead of replace!
Search and replace with Regex works fine, but you might want to edit your text afterwords (like commas that were there before the numbers, etc.).
Here is the function. Pattern is simply =RegexReplace(cell, "\d", "")
Function RegexReplace(ByVal text As String, _
ByVal replace_what As String, _
ByVal replace_with As String) As String
Dim RE As Object
Set RE = CreateObject("vbscript.regexp")
RE.Pattern = replace_what
RE.Global = True
RegexReplace = RE.Replace(text, replace_with)
End Function
How to do that using VBA...
Open an Excel workbook and paste the text you provided this way:
Let those rows selected.
Press “ALT+F11” to open the Visual Basic Editor.
Go to the Insert Menu and open a Module.
Type in this function:
Sub clear()
s = Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9")
For Each r In Selection
v = r.Value
For i = 0 To 9
v = Replace(v, s(i), "")
Next
r.Value = v
Next
End Sub
Click the green Play button to execute the VBA script.
Get back to the sheet and see the result (no more digits):