How to remove ALL numbers from a cell with a function or regex?

前端 未结 3 1652
逝去的感伤
逝去的感伤 2021-02-10 17:30

I have cells that look like this, one per line:

Duffy,John: \'Heritage: Civilization and the Jews\'- Fanfare & Chorale,Symphonic Dances + Orchestr

3条回答
  •  梦毁少年i
    2021-02-10 17:48

    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
    

提交回复
热议问题