Check if a value is in a string - excel-formula

I'm looking for a formula that will check each cell in Col A to see if it is contained anywhere in the cells in range B1:B3, then return a "true" or "false"
Col A Col B
ACAM-18QT-ANN ACAM-50PLD-ANN,ACAM-18QT-ANN,ACAM-72PL-AQU,
ACAM-50PLD-ANN POBIC-BR-SF,
ACPA-BR-SF ACPA-BR-SF,ACPA-TB2-T-MAN,

Use the SUMPRODUCT with SEARCH:
=SUMPRODUCT(ISNUMBER(SEARCH(A1,$B$1:$B$3))*1)>0

Related

Excel Conditional Formatting - Find Cells Value in Named Range, check found cell.offset for data

Im looking for a non-VBA way of highlighting a cell where its match in a named range does not have a value in its offset cell.
My origin cell is a two digit alpha numeric value, ie: A2. To determine the value to search I am using Left(Origin, 1) to extract the "A" as the value to search the named range for.
The named range "CodeX" covers the range("K3:K12, M3:M12, O3:O12").
I need to find "A" within the named range. Then, when A is found, I need to validate that the cell to the immediate right ie: offset(1, 0) has a value.
Where no value is found, the origin cell is to highlight through conditional formatting. I have attempted Index Match and Countif but not only can i not wrap my head around it, the formulas I've tried don't seem to like that my named range is not all in the one column.
I can do this via VBA, but would prefer not to as it screws around with other conditional formatting already in place.
That's a beast of a formula you're looking for. Here you go:
=IFERROR(INDIRECT("R"&ROW()&"C"&IF(
ISNUMBER(FIND("A",INDEX(CodeX,ROW(),1,1))),
COLUMN(INDEX(CodeX,ROW(),1,1))+1,
IF(ISNUMBER(FIND("A",INDEX(CodeX,ROW(),1,2))),
COLUMN(INDEX(CodeX,ROW(),1,2))+1,
IF(ISNUMBER(FIND("A",INDEX(CodeX,ROW(),1,3))),
COLUMN(INDEX(CodeX,ROW(),1,3))+1,
FALSE
))),FALSE)="",TRUE)
It's checking the current row for each of the 3 areas in range CodeX for that string A. If it finds it, it returns the column number of the cell tor the right, or else it checks the next area.
It uses the current row and the column number to find the value of the cell to the right of the matched cell. If the value is "" the cell is empty and your originating cell should be highlighted. If there is an error, A was not found and originating cell should be highlighted.
Edit: Here is the explanation:
INDEX(CodeX,ROW(),1,1) gets a reference to CodeX, current row, column 1, range group 1.
FIND("A",INDEX(CodeX,ROW(),1,1)) returns where (index number) string "A" is in the reference cell. If there is no "A", it returns an error.
ISNUMBER(FIND("A",INDEX(CodeX,ROW(),1,1))) returns TRUE if "A" was found and FALSE if not.
COLUMN(INDEX(CodeX,ROW(),1,1))+1 gets the column to the right of the reference.
INDIRECT("R"&ROW()&"C"&...,FALSE) gets the reference to the current row and 1 column to the right of "A" if found. If "A" was not found, it returns an error. the FALSE tells excel my reference type is in the R1C1 format.
=IFERROR(...="",TRUE) returns TRUE if the cell to the right of "A" equals "", FALSE if it as any value other than "" and it its an error ("A" was not found), returns TRUE.

Using IF AND statement in Excel formula doesn't work

Hello All,
I've alter question in simpler way.
Right now I'm working on image where Col A & B has some values. I've to find values in Col C, where if Col A values "No Windows" & Col B values "No SQL".
I've used formula of IF AND statement in Col C. The Col C will represent it as "Yes" where Col A values "No Windows" & Col B values "No SQL" else formula will reflect it as "no".
For reference: In Col D represent the actual result needed after formula is applied.
Formula used : IF AND statement in Excel
=IF(AND(A2="No Windows",B2="No SQL"),"Yes","no")
So sometimes the data tested has leading or trailing spaces, try using trim() like this:
=IF(AND(trim(A2)="No Windows",trim(B2)="No SQL"),"Yes","no")

Check id every value in ";" separated string exists on a LOV list using just Excel formulas

In a cell I have a multi value separated by semicolon like this:
Red;Blue;Green
I need to compare if each of those values exist on a list:
Black
Orange
Green
Blue
Red
I think it should be an array formula, but I have no idea how to set it.
Is it even possible?
Regards
MichaƂ
You've not mentioned what output you are looking for. Below are the two possible solution.
1. If you are looking for the count of words in a cell from the list use following formula:
=SUMPRODUCT(ISNUMBER(FIND($E$2:$E$6,$A2))*1)
2. If you want words in the cell that are in the list to be displayed in separate columns, use the following array formula
=IFERROR(INDEX($J$2:$J$6,SMALL(IF(ISNUMBER(FIND($J$2:$J$6,$A2)),ROW($J$2:$J$6)-ROW($J$1)),COLUMNS($A1:A1))),"")
Drag/copy above formula across and down as required.
Being an array formula you'll have to commit this formula by pressing Ctrl+Shift+Enter.
You can write this UDF and use it as a formula. Wasn't sure what output is required. This UDF gives number of items that match in the list.
Parameters:
myValue - the cell that contains multi value separated by semicolon
listRange - Range that has the list to check against. Should be a single column list
Function checkList(myValue As Range, listRange As Range) As Integer
Dim t As Variant
t = Split(myValue.Value, ";")
Dim c As Integer
c = 0
For i = LBound(t) To UBound(t)
For j = 1 To listRange.Rows.Count
If (t(i) = listRange(j, 1)) Then
c = c + 1
End If
Next j
Next i
checkList = c
End Function
Since you want to do this only with excel formulas, the input string has to be split to multiple cells before comparing it with the list.
If your input string is in A1, use the below formula and drag it right to split them based on the delimiter ;.
=TRIM(MID(SUBSTITUTE($A1,";",REPT(" ",999)),1+((COLUMN(A1)-1)*999),999))
Assuming your list is in column G, use the below formula which counts the strings Red, Blue and Green in your list and returns Found or Not found.
in C2,
=IF(COUNTIF($G:$G,C1),"Found","Not found")
Hope this helps.

Excel Sumifs with Multiple OR Criteria

I'm trying to build a Sumifs formula that uses multiple OR criteria, but also uses cell references in the criteria. I've found on other posts how to use an array constant (ie. Sumifs('Sum Range', 'Criteria Range', {value 1, value 2})) to achieve this, but array constants don't allow for cell references; only static-defined values.
Here's a simplified example my data: https://i.stack.imgur.com/OdfCN.png
I need to build a Sumifs formula in cell 'TABLE B'!C2 which returns the sum of Price values from column 'TABLE A'!C:C where:
('Table A'!A:A = 'TABLE B'!A:A or "ALL") AND ('Table A'!B:B = 'TABLE B'!B:B or "ALL")
This formula should return a value in 'TABLE B'!C2 of:
'TABLE A'!C3 +'TABLE A'!C4 + 'TABLE A'!C5
= $9.00
Thanks!
You would use this:
=SUMPRODUCT((('Table A'!$A$2:$A$5='TABLE B'!A2)+('Table A'!$A$2:$A$5="ALL"))*(('Table A'!$B$2:$B$5='TABLE B'!B2)+('Table A'!$B$2:$B$5="All")),'Table A'!$C$2:$C$5)

Excel: Check for partial matches from column against single cell

I have two columns in Excel:
Column A
Row 1 Apple
Row 2 Blueberry
Row 3 Strawberry
Column B
Row 1 App
Row 2 Application
Row 3 Appendage
I would like to use Column B to see if any cells within it exist within the given cell in Column A. So far, I have used the VLOOKUP and MATCH functions and I can't seem to get either to work properly, but MATCH seems to be the one I should be using. I tried using wildcards on Column B and it returns a value error. Here is what I have:
=MATCH(A1,"*"&B:B&"*",0)
Your help is greatly appreciated!
There is a natural VBA solution. In a standard code module place:
Function PartialMatch(v As Variant, R As Range) As Variant
Dim i As Long
For i = 1 To R.Cells.Count
If v Like "*" & R.Cells(i).Value & "*" Then
PartialMatch = i
Exit Function
End If
Next i
PartialMatch = CVErr(xlErrNA)
End Function
Then where you want it in a spreadsheet you can use the formula:
=PartialMatch(A1,B:B)
It will give the index of the first partial match, if any exists, or #N/A if it doesn't. Note that a blank cell counts as a partial match, so you might want to make sure that the range that you pass the function contains no blanks (so don't pass the whole column). That, or redefine what you mean by a partial match.

Resources