简体   繁体   中英

Excel find cells from range where search value is within the cell

Once again I'm struggling to find my answer on Google, but I'm sure it must exist. Sorry if I come across as a novice: I am when it comes to Excel it seems!

What I'd like to be able to do is tell it to search a range, then find cells within that range that contain text that is in my search function. I don't need any kind of result from it other than either TRUE or >1 (if it matches, obviously).

In this instance I'm searching a RANGE that is comprised of years, one year in each cell, and trying to find cells in that range that contain a year from a list of years that are all in one cell.

Basically I'm wanting to use a function similar to the Search function I think.

=SEARCH(text to find, find within text)

However, I'd like it to do the opposite and find cells that contain some of the text within the source cell:

=SEARCH(find within text, text to find)

Or, more specifically

=SEARCH("2001,2002,2003,2004,2005", "2003")

Is this possible without the use of a Macro? I'd prefer to avoid it if at all possible. All cells in question are formatted as Text.

I have been experimenting with COUNTIF, but again it works in the reverse of what I need.

Sorry if this question is unclear. Hope someone can help, thanks in advance.

Joe

I'm sure there is a better way, but if I'm understanding correctly, you could try SUM in combination with an array formula (enter with Ctrl+Shift+Enter ):

=IF(SUM(IFERROR(FIND(A1:E1,G1),0))>0, "FOUND", "NOT FOUND")

Here, A1:E1 contained the individual years and G1 contained the single cell of years. This runs FIND on each cell in the range, returning a position if it finds a match in the target cell and returning 0 if not ( IFERROR is a 2007 function - if you don't have Excel 2007, we can rewrite). You then sum the results of the FIND function and if it is greater than 0, it means you found a match somewhere.

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM