【发布时间】:2019-02-26 16:12:46
【问题描述】:
问题
给定 Excel 中某个范围内的子字符串列表,例如:
子串表
[A1:A3]
Apple
Banana
Carrot
我希望返回这些子字符串中的哪一个出现在包含文本的单元格中,例如:
文本单元格
[A5]
The Apple fell from the tree
方法/公式将返回:Apple
原因:
每个月我都会导入几百个包含文本并需要分类的单元格。最常见的子字符串将在顶部的子字符串范围内,导入的文本单元格将有一个相邻的列,其中包含一个公式,如果存在则输出哪个子字符串,从而节省大量用户时间。所需的输出示例是:
期望的输出
*Table of text cells* | *Output referencing substring table* [A5:B5]
The Apple fell from the tree | Apple
A Carrot grows in the ground | Carrot
There was a bag of rotten Apples | Apple
Watch out for that Orange |
The monkey ate the Banana | Banana
通过修补和研究得出最接近的公式
我得到的最接近的是一个公式,如果存在子字符串(返回 1 或 0)则返回:
=SUMPRODUCT(--ISNUMBER(SEARCH($A$1:$A$3,A5)))
使用这个公式和上面的“期望输出”示例,我会看到:
[A5:B5]
The Apple fell from the tree | 1
A Carrot grows in the ground | 1
There was a bag of rotten Apples | 1
Watch out for that Orange | 0
The monkey ate the Banana | 1
这是在此论坛上推荐的,用于 TRUE/FALSE 测试,但我无法适应我的需求。非常感谢任何建议:)
【问题讨论】:
标签: arrays excel text excel-formula substring