Forum Discussion

Extopia's avatar
Extopia
Copper Contributor
Dec 17, 2025
Solved

Logical test for same text string existing anywhere in both ranges.

Hello. I have a Table of film credits, including the names of directors and writers. Some films have multiple directors (up to 3 individuals), whose names are in columns F, G and H. The writers' names (up to 4 individuals) are in columns J, K, L and M.

I want to test for whether the film has a writer/director - e.g, one of the director names in the range F:H is the same as one of the writer names in the range J:M.

I have created a column O to contain a formula with a logical test returning Y if there is a writer/director present.

I tried =IF(Table4[@[Wri1]:[Wri4]]=[@Dir1]:[Dir3],Y,N) but this returns a spill error.

Can anyone help?

 

10 Replies

  • Lorenzo's avatar
    Lorenzo
    Silver Contributor

    Variant that will work with Excel >/= 2021:

    =IF(
      SUM(
        --(XLOOKUP( Table4[@[Dir1]:[Dir3]], Table4[@[Wri1]:[Wri4]], Table4[@[Wri1]:[Wri4]], "(n/a)" ) <> "(n/a)")
      ),
      "Y", "N"
    )

     

    • Lorenzo's avatar
      Lorenzo
      Silver Contributor

      Hi
      Still with your Table4 a 365 option:

      =IF(
        SUM(
          IFNA(
            XMATCH( TOCOL( IFS(Table4[@[Dir1]:[Dir3]] <> "(n/a)", Table4[@[Dir1]:[Dir3]]), 2 ),
                    TOCOL( IFS(Table4[@[Wri1]:[Wri4]] <> "(n/a)", Table4[@[Wri1]:[Wri4]]), 2 )
            ),
            0
          )
        ),
        "Y", "N"
      )

       

      • Extopia's avatar
        Extopia
        Copper Contributor

        Thanks Lorenzo - unfortunately that returns an error if ALL director name fields contain "(n/a)" (e.g. the second row in my screenshot). 

  • Extopia's avatar
    Extopia
    Copper Contributor

    These solutions are promising, but I should have mentioned that I would like the formula to ignore the text string "(n/a)", which is in many columns and therefore creates a false match. Can this string be excluded? 

  • Lorenzo's avatar
    Lorenzo
    Silver Contributor

    Hi

    =IF( SUM( IFNA( XMATCH( Table4[@[Dir1]:[Dir3]], Table4[@[Wri1]:[Wri4]] ), 0 ) ), "Y", "" )

     

Resources