Excel-从文本中提取所有日期

时间:2018-08-24 15:08:52

标签: excel excel-formula

假设我有以下情况:

Today's Date is 08/20/2020 and tomorrow's date is 30/10/2018. Status = N/A
Yesterday's Date status is stuff/things but it  is 2020/08/31 and today is 8/20/18.

我要退货的是

08/20/2020, 30/10/2018
2020/08/31, 08/20/18

关于如何执行此操作的任何建议?

1 个答案:

答案 0 :(得分:1)

在数组公式中使用TEXTJOIN:

=SUBSTITUTE(TEXTJOIN(", ",TRUE,IF(ISNUMBER(SEARCH("*/*/*",TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",99)),(ROW($1:$25)-1)*99+1,99)))),TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",99)),(ROW($1:$25)-1)*99+1,99)),"")),".","")

作为数组公式,退出编辑模式时需要使用Ctrl-Shift-Enter而不是Enter进行确认。

TEXTJOIN是Office 365 Excel引入的

enter image description here


如果您没有Office 365,则每个“日期”的输出必须位于不同的单元格中。

将其放在B1中,上下复制:

=IFERROR(SUBSTITUTE(TRIM(MID(SUBSTITUTE($A1," ",REPT(" ",99)),(AGGREGATE(15,6,ROW($1:$25)/(ISNUMBER(SEARCH("*/*/*",TRIM(MID(SUBSTITUTE($A1," ",REPT(" ",99)),(ROW($1:$25)-1)*99+1,99))))),COLUMN(A:A))-1)*99+1,99)),".",""),"")

enter image description here