I am looking for a way to be more efficient or condense the following formula. The goal is for it to search 2 consecutive cells to see if they contain the character in cell Settings!$A$5,R5. If yes, then it will return the value of another referenced cell. If not, it will look at the next two consecutive cells. It continues until it finds two consecutive cells that contains the character in cell Settings!$A$5,R5. The formula works, I just feel like there has to be a more efficient way to do it.
=IF(And((ISNUMBER(SEARCH(Settings!$A$5,Q5))),(ISNUMBER(SEARCH(Settings!$A$5,R5)))),Settings!$F$6,IF(And((ISNUMBER(SEARCH(Settings!$A$5,R5))),(ISNUMBER(SEARCH(Settings!$A$5,S5)))),Settings!$F$6,IF(And((ISNUMBER(SEARCH(Settings!$A$5,S5))),(ISNUMBER(SEARCH(Settings!$A$5,T5)))),Settings!$F$6,IF(And((ISNUMBER(SEARCH(Settings!$A$5,T5))),(ISNUMBER(SEARCH(Settings!$A$5,U5)))),Settings!$F$6,IF(And((ISNUMBER(SEARCH(Settings!$A$5,U5))),(ISNUMBER(SEARCH(Settings!$A$5,V5)))),Settings!$F$6,IF(And((ISNUMBER(SEARCH(Settings!$A$5,V5))),(ISNUMBER(SEARCH(Settings!$A$5,W5)))),Settings!$F$6,IF(And((ISNUMBER(SEARCH(Settings!$A$5,J2))),(ISNUMBER(SEARCH(Settings!$A$5,K2)))),Settings!$F$5,IF(And((ISNUMBER(SEARCH(Settings!$A$5,K2))),(ISNUMBER(SEARCH(Settings!$A$5,L2)))),Settings!$F$5,IF(And((ISNUMBER(SEARCH(Settings!$A$5,L2))),(ISNUMBER(SEARCH(Settings!$A$5,M2)))),Settings!$F$5,IF(And((ISNUMBER(SEARCH(Settings!$A$5,M2))),(ISNUMBER(SEARCH(Settings!$A$5,N2)))),Settings!$F$5,IF(And((ISNUMBER(SEARCH(Settings!$A$5,N2))),(ISNUMBER(SEARCH(Settings!$A$5,O2)))),Settings!$F$5,IF(And((ISNUMBER(SEARCH(Settings!$A$5,O2))),(ISNUMBER(SEARCH(Settings!$A$5,P2)))),Settings!$F$5,IF(And((ISNUMBER(SEARCH(Settings!$A$5,C2))),(ISNUMBER(SEARCH(Settings!$A$5,D2)))),Settings!$F$4,IF(And((ISNUMBER(SEARCH(Settings!$A$5,D2))),(ISNUMBER(SEARCH(Settings!$A$5,E2)))),Settings!$F$4,IF(And((ISNUMBER(SEARCH(Settings!$A$5,E2))),(ISNUMBER(SEARCH(Settings!$A$5,F2)))),Settings!$F$4,IF(And((ISNUMBER(SEARCH(Settings!$A$5,F2))),(ISNUMBER(SEARCH(Settings!$A$5,G2)))),Settings!$F$4,IF(And((ISNUMBER(SEARCH(Settings!$A$5,G2))),(ISNUMBER(SEARCH(Settings!$A$5,H2)))),Settings!$F$4,IF(And((ISNUMBER(SEARCH(Settings!$A$5,H2))),(ISNUMBER(SEARCH(Settings!$A$5,I2)))),Settings!$F$4,""))))))))))))))))))
=IF(And((ISNUMBER(SEARCH(Settings!$A$5,Q5))),(ISNUMBER(SEARCH(Settings!$A$5,R5)))),Settings!$F$6,IF(And((ISNUMBER(SEARCH(Settings!$A$5,R5))),(ISNUMBER(SEARCH(Settings!$A$5,S5)))),Settings!$F$6,IF(And((ISNUMBER(SEARCH(Settings!$A$5,S5))),(ISNUMBER(SEARCH(Settings!$A$5,T5)))),Settings!$F$6,IF(And((ISNUMBER(SEARCH(Settings!$A$5,T5))),(ISNUMBER(SEARCH(Settings!$A$5,U5)))),Settings!$F$6,IF(And((ISNUMBER(SEARCH(Settings!$A$5,U5))),(ISNUMBER(SEARCH(Settings!$A$5,V5)))),Settings!$F$6,IF(And((ISNUMBER(SEARCH(Settings!$A$5,V5))),(ISNUMBER(SEARCH(Settings!$A$5,W5)))),Settings!$F$6,IF(And((ISNUMBER(SEARCH(Settings!$A$5,J2))),(ISNUMBER(SEARCH(Settings!$A$5,K2)))),Settings!$F$5,IF(And((ISNUMBER(SEARCH(Settings!$A$5,K2))),(ISNUMBER(SEARCH(Settings!$A$5,L2)))),Settings!$F$5,IF(And((ISNUMBER(SEARCH(Settings!$A$5,L2))),(ISNUMBER(SEARCH(Settings!$A$5,M2)))),Settings!$F$5,IF(And((ISNUMBER(SEARCH(Settings!$A$5,M2))),(ISNUMBER(SEARCH(Settings!$A$5,N2)))),Settings!$F$5,IF(And((ISNUMBER(SEARCH(Settings!$A$5,N2))),(ISNUMBER(SEARCH(Settings!$A$5,O2)))),Settings!$F$5,IF(And((ISNUMBER(SEARCH(Settings!$A$5,O2))),(ISNUMBER(SEARCH(Settings!$A$5,P2)))),Settings!$F$5,IF(And((ISNUMBER(SEARCH(Settings!$A$5,C2))),(ISNUMBER(SEARCH(Settings!$A$5,D2)))),Settings!$F$4,IF(And((ISNUMBER(SEARCH(Settings!$A$5,D2))),(ISNUMBER(SEARCH(Settings!$A$5,E2)))),Settings!$F$4,IF(And((ISNUMBER(SEARCH(Settings!$A$5,E2))),(ISNUMBER(SEARCH(Settings!$A$5,F2)))),Settings!$F$4,IF(And((ISNUMBER(SEARCH(Settings!$A$5,F2))),(ISNUMBER(SEARCH(Settings!$A$5,G2)))),Settings!$F$4,IF(And((ISNUMBER(SEARCH(Settings!$A$5,G2))),(ISNUMBER(SEARCH(Settings!$A$5,H2)))),Settings!$F$4,IF(And((ISNUMBER(SEARCH(Settings!$A$5,H2))),(ISNUMBER(SEARCH(Settings!$A$5,I2)))),Settings!$F$4,""))))))))))))))))))