=ISNUMBER(SEARCH()) formula not working properly - excel

Basically, im trying to search if values from column b is contained in cells on column a
I am currently using the formula
=ISNUMBER(SEARCH(B1,$A:$A))
and using it inside a conditional formatting to highlight the cells in column A that contains strings from column B. But it is not highlighting the correct cells
any advice?

Problem is that your ISNUMBER(SEARCH(…. formula is returning an array of values {FALSE;TRUE;FALSE;FALSE;...} one return for each item in within_text. You need to know if any of those items match.
So, with your formula, consider the array formula modification
=OR(ISNUMBER(SEARCH(B1,$A:$A)))
Since this is an array formula, you need to "confirm" it by holding down ctrl + shift while hitting enter. If you do this correctly, Excel will place braces {...} around the formula as observed in the formula bar
If you don't like to use the CSE entry method, you could use this formula which will return zero for no matches, or be non-zero for any matches:
=SUMPRODUCT(-ISNUMBER(SEARCH(B1,$A:$A)))

Excel's SEARCH function is used to find the position of one string within another string. Generally you use it like this:
=SEARCH("String A", "A Longer String Containing String A")
This will return the character index where first string starts within the second string, which in this case would be 28.
What you really need is a VLOOKUP. Since you're doing a textual search (substring), you need your range to be of text type instead of number.
You should do the following:
Add an extra column to the right of Column A and use TEXT function to convert entries to textual form:
=TEXT(A1, "#")
Now you can use VLOOKUP to perform a substring-match in this textual range. VLOOKUP supports wildcards when you do not ask it to perform an exact match (4th argument should be FALSE). Here is your formula then:
=VLOOKUP("*" & C1 & "*",$B:$B,1,FALSE)
Note that I have passed column B (textual column) as the lookup range, whereas C1 is the cell containing the text that you want to search.
This method also has the additional advantage that it returns the actual matched entry from the range so you don't have to find it manually.
Once you have your results, you can apply conditional formatting to it.

Highlight column A (or the relevant range in column A starting cell A1) with the first cell (which is A1 in this case) as the active cell, use the following formula as the conditional formatting rule:
=(SEARCH($B1,$A1)*(LEN($B1)>0))>0
The logic is to first search the given sub-string from the main string, then multiple the result by LEN($B1)>0 to exclude the result of 1 returned for blank cells in column B.
Note: Conditional Formatting works in array fashion so even though the formula only looks at values in the first row of the range, as long as you use the relative (or in some cases absolute) cell references correctly and highlight the result range correctly before setting up the rule, the rule will be applied across in the same way as for the first row of the array as demonstrated in this example.

Related

Find common text within a range of cells(range containing blanks as well)

This is the problem i am facing in Excel formula
enter image description here
In column F, i want to find the common text across A2 to E2 (containing Blanks)
My Question:
Is there a simple way to get the result without VB?
Any help is appreciated,thanks
I found that google sheets has some really cool functions.
If you put the formula =SPLIT(A1, ",", TRUE,FALSE) in the cell after your row of common text (or probably even in a different sheet - "probably because hadn't tried it, though it should), the next x cells (where x is the number of "," in A1 - because "," is the delimitator) will be the text.
then you can put the code =IF(SUM(ARRAYFORMULA(if(REGEXMATCH($A$1:$D$1,F1),1,0)))=COUNTA($A$1:$D$1),F1,"") into an equal number of cells after that (probably should just put into the max number), and =CONCATENATE(I1:L1) into the last cell.
Ok. So to tweak this for yourself: I found that ARRAYFORMULA lets you put an array in place of a single cell in a function inside. how it exactly works I read its like a for loop. but I can't really vouch for that. but here it lets you have REGEXMATCH (which is a Boolean check on the cell you give it for if it contains the given REGEX) check each cell in the array.
the sum will add them up, and the if will match against the COUNTA to find if the number of cells in the array that contain this string is equal to the number of non-empty cells.
the concatenate at the end adds all the cells (containing the regex function) together, and since the only non-empty cells will be the one with the string, that is what this cell will return (no spaces).
code:
results:
the test data:
If you need in specifically Excel... this won't help.
We can use power query to achieve the desired result.
Unpivot the columns in Power query
Split all the columns by Comma delimiter
Create a custom column to see if the first column records exist in the remaining columns.
Use the functionText.contains.
Sample function: =Text.Contains([column.1],[column.1]&[column.2]&[column.3])
If the above function returns TRUE then get the first column result(This is the expected result) and load the data back to your excel

Excel: dynamically calculate range next to a searched up cell

I am an occasional Excel user and stuck how to create a dynamic range.
After looking up a text in a table, how can I calculate the range next to this cell, up to the next empty row? Not using VBA.
Thanks for your help.
In H4, formula copied down :
=IFERROR(INDEX(INDEX(C:C,MATCH(F4,A:A,0)):C$1000,MATCH(G4,INDEX(B:B,MATCH(F4,A:A,0)):B$1000,0)),"")
Should you want a dynamic range,
Change C$1000 to INDEX(C:C,MATCH(9.9E+307,B:B)
and
Change B$1000 to INDEX(B:B,MATCH(9.9E+307,B:B))
Then
The H4 copied down formula become :
=IFERROR(INDEX(INDEX(C:C,MATCH(F4,A:A,0)):INDEX(C:C,MATCH(9.9E+307,B:B)),MATCH(G4,INDEX(B:B,MATCH(F4,A:A,0)):INDEX(B:B,MATCH(9.9E+307,B:B)),0)),"")
Edit :
As per Ron Rosenfeld's comment, "should B11 change to 24 and G4 change to 24"
The "Source Table" set up in Excel Table type for dynamic range growing purpose
and
The H4 formula change to :
=IFERROR(LOOKUP(9^9,Table1[price]/(LOOKUP(ROW(Table1[texture]),ROW(Table1[texture])/(Table1[texture]<>""),Table1[texture])=F4)/(Table1[length]=G4)),"")
Combining the Index() and Match() functions usually works well when using two conditions. However, you will need to fill out the entire column A with the "texture" list in order for the below formula to work.
=INDEX(<P1>, MATCH(TRUE, (<T1>=<T2>) + (<L1>=<L2>) > 1,0))
Where <P1> is your entire price column (ex. C2:C15)
Where <T1> is your entire texture column (ex. A2:A15)
Where <T2> is your texture lookup value cell
Where <L1> is your entire length column (ex. B2:B15)
Where <L2> is your length lookup value cell
Let's say that you input your texture value into cell F3, and your length value into cell F4. With the remaining columns remaining as they are in your image, you would use the following formula:
=INDEX(C2:C15, MATCH(TRUE, (A2:A15=F3) + (B2:B15=F4) > 1,0))
Now last time I had to use Index/Match I thought I had to place the formula into an array. However, the above seems to work without it.
If you notice that it's not working as expected, you can place into an array formula by clicking the cell that contains the formula, then clicking the formula box at the top. While in the formula box, simultaneously press Ctrl + Shift + Return. This should then place curly brackets around your entire formula if done properly, as such:
If you have O365 with the SEQUENCE function, you can use, for price:
=IF(G4="","",VLOOKUP(G4,INDEX($B:$C,SEQUENCE(MATCH(TRUE,ISBLANK(INDEX($B:$B,MATCH(F4,$A:$A,0)):INDEX(B:B,ROWS(B:B)-MATCH(F4,$A:$A,0))),0)-1,,MATCH(F4,$A:$A,0)),{1,2}),2,FALSE))
explanation:
get starting row:
MATCH(F4,$A:$A,0)
ending row will be the first blank row after the starting row:
MATCH(TRUE,ISBLANK(INDEX($B:$B,MATCH(F4,$A:$A,0)):INDEX(B:B,ROWS(B:B)-MATCH(F4,$A:$A,0))),0)
Construct the relevant array:
INDEX($B:$C,SEQUENCE(MATCH(TRUE,ISBLANK(INDEX($B:$B,MATCH(F4,$A:$A,0)):INDEX(B:B,ROWS(B:B)-MATCH(F4,$A:$A,0))),0)-1,,MATCH(F4,$A:$A,0)),{1,2})
The above might reduce (with wavy) to:
index(b:c,{9,10,11},{1,2}
Then it's just a matter of applying the VLOOKUP
A more understandable, but longer with more operations, formula available in O365 makes use of LET. The advantage is that one can use names which indicate what each section of the formula does.
For example:
=IF(G4="","",LET(startRow,MATCH(F4,$A:$A,0),numRows,MATCH(TRUE,ISBLANK(INDEX($B:$B,startRow):INDEX($B:$B,ROWS($B:$B)-startRow)),0)-1,
arr,INDEX($B:$C,SEQUENCE(numRows,,startRow),{1,2}),price,XLOOKUP(G4,INDEX(arr,0,1),INDEX(arr,0,2)),price))
Or, using VLOOKUP
=IF(G4="","",VLOOKUP(G4,LET(startRow,MATCH(F4,$A:$A,0),numRows,MATCH(TRUE,ISBLANK(INDEX($B:$B,startRow):INDEX($B:$B,ROWS($B:$B)-startRow)),0)-1,arr,INDEX($B:$C,SEQUENCE(numRows,,startRow),{1,2}),arr),2,FALSE))
Finally, for earlier versions of Excel, you can use this whopper where we replace the SEQUENCE function with a construct like: ROW(INDEX(A:A,firstRow):INDEX(A:A,lastRow))
=IF(G4="","",VLOOKUP(G4,INDEX($B:$C,ROW(INDEX($A:$A,MATCH(F4,$A:$A,0)):INDEX($A:$A,MATCH(F4,$A:$A,0)+MATCH(TRUE,INDEX($B:$B,MATCH(F4,$A:$A,0)):INDEX($B:$B,ROWS($B:$B))="",0)-2)),{1,2}),2,FALSE))

Searching within a list of strings with anything in another list of strings in Excel

Example Data
I need to find anything in column B within the strings in Column A and output the cell in Column A in Column C.
I know if it is a short list I can do the highlight cell if a text contains x with Conditional Formatting. However, I have a long list of items that I need to check within the strings of another list.
Let me know if anymore detail needs to be provided. Any help is appreciated. Thanks.
Try this Array formula with wildcards:
=IF(ISNUMBER(MATCH(1, IF(ISNUMBER(SEARCH("*"&$B$1:$B$3&"*",A1)),1,0),0)),"Y","N")
It is an array and need to be confirmed with Ctrl-Shift-Enter.
The search area represented in this small example, $B$1:$B$3 when enlarged must be to the exact range of lookups or it will not return correct values.
You can do this with array formula, type the following in cell C1, then press Ctrl + Shift + Enter:
=INDEX(B:B,MATCH(TRUE,FIND(B:B,A1)<>"#VALUE!",0))
Drag it down column C to match number of rows in column A. You can then put a conditional formatting/filter to see what row in A has substring in B.
If you simply want a yes/no result, enter the following into D1:
=IF(COUNTIF(C1:C6,"<>0")>0,"Found","Not Found")

Excel MATCH character limit

I use the following formula =INDEX(Dict!A:A,MATCH(A2,Dict!A:A,0),1) but MATCH only works with text below 256 characters. Any way to overcome this limitiation?
To accommodate partial matches use SEARCH like this:
=INDEX(Dict!A:A,MATCH(TRUE,INDEX(ISNUMBER(SEARCH(A2,Dict!A:A)),0),0))
That will work to return a value > 256 characters but A2 can't be > 256 characters
You can use the LDMP look-up method, taking advantage of the concat formula available since the Excel 2016.
={CONCAT(IF(Value=A:A;B:B;"")}
Note that it is a matrix formula so you must enter it CTRL + SHIFT + ENTER.
Additionally the formula returns not only the first value but all the matching values.
There is another way to do this, if you don't mind the messiness of a helper column, and your original formula is not being repeated in subsequent rows (i.e. matching cells A3, A4, A5...). The helper column can of course be hidden to keep DICT looking pretty.
Insert (or use) a column (say B:B) next to A:A in DICT!, and populate it with a simple formula "=A1=SHEET1!A$2" (SHEET1 being the name of your source/original sheet), which will populate the column with TRUE and FALSE values, indicating which rows (if any) in DICT match to A2.
The match syntax then changes from "MATCH(A2,Dict!A:A,0)" to "MATCH(TRUE,Dict!B:B,0)".
Note: I know this works in principle as I have just done it, but if I added a typo in retrofitting it to the example provided, apologies, however the principle should be easy to follow.

Matching two columns in one sheet to two columns in another

I need to assign a status to a row based on a VLOOKUP query between two worksheets. The problem is that the identifier is not always unique. However, the identifier + a date value should be unique. I wanted to use:
=VLOOKUP(A3&H3,'OtherSheet'!D:E,1,FALSE)
with A3 being the identifier and H3 being the corresponding date. D in the other sheet is the identifier and E is the date column. However, I keep getting #N/A.
Does this mean that there are no matches with the "identifier+date" or is Excel looking for "identifier+date" in either column D or E? If the latter is true, how can I let Excel concatenate D and E when matching to the search pattern?
There's work around without using CTRL+Shift+Enter.
Use this formula that will match A3 in D column of othersheet and H3 with the date in column E of the othersheet.
=INDEX(OtherSheet!F:F,MATCH(1,INDEX((OtherSheet!D:D=A3)*(OtherSheet!E:E=H3),),0))
The formula will return data from F column of OtherSheet.
You can modify the range OtherSheet!F:F as appropriate.
That formula is looking to find A3 concatenated with H3 (identifier&date) in OtherSheet ColumnD that contains only identifiers, so will inevitably fail. Yes, Excel is looking for “identifier+date” in column D.
Excel will happily concatenate A3 with H3 ‘on the fly’ (within a formula) but will not so happily concatenate OtherSheet ColumnD and ColumnE values in the same way. The conventional solution, because usually simplest in a case like this, is to prepare for the VLOOKUP by adding a helper column that concatenates the D and E values while preserving these in the same row as the value sought.
Because VLOOKUP will only look to the right this is usually a column that is added to the left of the value being searched for, so say either in C or by insertion of a column immediately to the right of C. However, since you are only checking a single column the location is not critical. You might add this (in OtherSheet) as ColumnZ, with a formula such as:
=D2&E2
copied down to suit*. Again because you are only checking a single column it does not matter which row such a formula is placed in.
However, because only checking whether A3&H3 exists in OtherSheet a simple alternative may be to apply COUNTIFS:
=COUNTIFS(OtherSheet!D:D,A3,OtherSheet!E:E,H3)
Any result other than 0 from this should indicate that the combination being tested for exists in OtherSheet – without need for a helper column.
* Depending on the format of your identifiers it is possible that concatenation may introduce ambiguity. For example ID90 concatenated with 11/1/15 may not be distinguishable from ID901 concatenated with 1/1/15, so it may be advisable if taking this approach to introduce a delimiter, in both the VLOOKUP formula (say A3&"|"&H3 rather than just A3&H3) and therefore also in the helper column, say =D2&"|"&E2.
You likely would want to use Index/Match instead. Vlookup is tricky when it comes to searches for multiple things. Here's the way you would use Index/Match:
Without knowing how your spreadsheet is set up, here's how you could do it:
If I understand correctly, you want to use A3 to find the match in OtherSheet!D, and H3's match in OtherSheet!E. Index match is perfect for this. Instead of vLookup, use
=Index(OtherSheet!D:D&","&Text(OtherSheet!E:E,"mm-dd-yyyy"),Match(A3&H3,OtherSheet!D&OtherSheet!E,0)), and enter with CTRL+SHIFT+ENTER.
What the Index() will return is the concatenated Identifier and Date, separated with a comma. If, though, you have a table like this:
That index/match formula will return "Batman". The index to return is the named range G2:G5. You're looking for a match on A1 (the Identifier) and B1 (the Date), then you're searching for (in the order you just put) the Identifier to be in the range E2:E5, and the Date to be in F2:F5. When there's a match for both, it returns the name in G2:G5.
Here's a link to a site on using Index/Match, and another and its advantages over vlookup.

Resources