Home > Enterprise >  IF text is found in a list
IF text is found in a list

Time:10-03

I am trying to create an IF statement that includes checking if a cell contains a text string from a list of text strings and I'm struggling with the correct way of doing it.

I have a 'Global Settings' page, with the values I want to search against (which are named ranges to make things cleaner).

enter image description here

Then in my Calcs sheet, I have column J which works correctly when the named range from the Global Settings is just one word and matches what's in column A.

But column K is the one I can't get to work, where I'm trying to check if the Post Type in column A is in the list of Page Types in the named range.

This is the formula I have:

=IF(B2>100, IF(A2=PageTypes, "Right Page Type", "Wrong Page Type"),"<100")

enter image description here

Logically I think I need to change the 'A2=PageTypes' part to somehow tell sheets to say if 'A2 is contained in the string of PageTypes' but I have no idea how I would do that.

Link to the spreadsheet here https://docs.google.com/spreadsheets/d/1TeaQ6oUbJDeKxUi8tvvCWXtw0oK9d5IVO60j1UbQCK8/edit?usp=sharing

CodePudding user response:

somehow tell sheets to say if 'A2 is contained in the string of PageTypes

=IF(B2>100, IF(REGEXMATCH(PageTypes, A2), 
 "Right Page Type", "Wrong Page Type"),"<100")

or:

=IF(B2>100, IF(IFERROR(SEARCH(A2,PageTypes)>0, 0), 
 "Right Page Type", "Wrong Page Type"), "<100")
  • Related