Formula to extract numbers from a text string

前端 未结 3 1547
無奈伤痛
無奈伤痛 2020-12-22 03:40

How could I extract only the numbers from a text string in Excel or Google Sheets? For example:

A1 - a1b23eg67
A2 - 15dgrgr156

Result desir

3条回答
  •  春和景丽
    2020-12-22 03:59

    Because you asked for Excel also,

    If you have a subscription to office 365 Excel then you can use this array formula:

    =--TEXTJOIN("",TRUE,IF(ISNUMBER(--MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)),MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1),""))
    

    Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. If done correctly then Excel will put {} around the formula.

提交回复
热议问题