Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

In Google Sheets search for a string in a column, then return the row where found

$
0
0

In Google Sheets, I have two columns of data.

The first column is labeled Category, and the second Contents

I want to search Contents for a text string and return Category wherever it is matched.

For example, in the table below, if I search Contents for the phrase amino acids I would expect the formula to return both Proteins and Urea cycle from Category:

CategoryContents
Proteinsamino acids, alpha-helix, beta-sheet, primary structure, secondary structure, tertiary structure
Urea cycle transamination, amino acids, urea, glutamine, glutamate, liver, kidney
  • I've tried using the functions INDEX and MATCH but it only matched if the search term was the only text in the cell, as opposed to part of comma-separated values (CSV).

  • XLOOKUP failed for the same reason

  • I thought about splitting the CSV into an array using SPLIT but that creates a 2-dimensional array that MATCH doesn't support.

  • The closest I've gotten is the following formula but it returns the matching Contents instead of the Category:

      =FILTER(B:B, REGEXMATCH(B:B, "amino acids"))

Maybe an array formula is required.

How do I return multiple results from Category based on matching text substrings in Contents?


Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>