查找由excel中的字母和数字组成的子字符串

时间:2017-06-04 22:33:04

标签: excel string

我目前正在处理需要分析的数据集。它是从遗留数据库上传的,它只是将所有字段连接在一起,但不同的字段对于不同的数据点都是空的,所以没有简单的方法来分割它们。

如果我可以在包含字母和数字的单词的第一次出现时拆分字符串(例如abc123),我已经确定我可以从中提取有用的信息。不幸的是,我无法使用支持宏的工作簿,因此没有VBA或正则表达式可以轻松实现。

无论如何确定字符串或子字符串是否包含字母和数字的组合?

示例数据:

2283-332-44543 CAP DDT @ PPL445 HEEN PAX 77820

44372-33-3223 TYYTE CAP BOX 1550 244 BOX PPSSA223 PAX

PRECISE 77 CLEAR BLUE 99WIE BOX 4403 PAX SSKA

2 个答案:

答案 0 :(得分:0)

The first block (C1:C3) is the source data. The second (C5:K5) after parsing (a copy) of that with Text to Columns, Space delimited. The third block has this horrible formula in C9 (copied across and down to suit):

   =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(C5,0,""),1,""),2,""),3,""),4,""),5,""),6,""),7,""),8,""),9,""),"-","")

The fourth block under the rest has this in C13, copied across and down to suit:

=AND(LEN(C9)<>0,LEN(C9)<>LEN(C5))  

To avoid getting in the way of blocks of unknown length, this:

=MATCH(TRUE,(C13:K13),0)  

is in A13 and copied down to suit. The 'output' is in B13 and below, ready for Copy, Paste Special, Values somewhere suitable and then parsing with pipe as the delimiter.

SO44359450 example

The results from the example should be, in two columns:

2283-332-44543 CAP DDT@ PPL445                      EEN PAX 77820
44372-33-3223 TYYTE CAP BOX 1550 244 BOX PPSSA223   AX
PRECISE 77 CLEAR BLUE 99WIE                         OX 4403 PAX SSKA

答案 1 :(得分:0)

I managed an awful solution that seemed to work:

First, split the data using text to columns. Then, for each cell, use:

=AND(COUNT(FIND({0,1,2,3,4,5,6,7,8,9},A2))>0, NOT(ISNUMBER(A2)) )

After that, it was easy to concatenate all the ones proceeding the first true together, giving me actual useful data.

Thanks everyone for the help.