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

前端 未结 3 1468
你的背包
你的背包 2021-02-10 17:10

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

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

3条回答
  •  被撕碎了的回忆
    2021-02-10 17:58

    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
    

提交回复
热议问题