Excel find, match and mark wildcards - excel

I am trying to do a search based on values that are in column B and find string in column A, example:
Column A
abc, cde | abc, 1234 | cde | abc, etc
Column B
abc, cde
I am trying to use values that are in column B and search and match in column A and return value of match/no match in column C.
I tried using MATCH(B1,A:A) function and return value of match or no match but its all returning no match and its not searching the values on column A that have the |
Any formulas I can use?

If what you want is getting a boolean value, i.e TRUE or FALSE, which tells you if the string in cell B1 is somewhere in the string value of cell A1, you can do
=NOT(ISERR(SEARCH(B1,A1)))
The SEARCH function gets the value in cell A1 and tries to find it within the string value contained in cell B1. I say "trie" since it may return an error if it finds nothing.
Thus ISERR(SEARCH(...)) checks for an error and returns TRUE if there is one, which in this case would mean that the velue in cell B1 does not match the one in cell A1.
Finally, to turn the output of function ISERR into the boolean answer you want, we negate it, by doing NOT(ISERR(...)).
Example 1
Checking whether each string value in column B is CONTAINED in cell A1's string value
A B C
1 abc, cde | abc, 1234 abc, cde =NOT(ISERR(SEARCH($B1,$A$1)))
2 zyy | xww =NOT(ISERR(SEARCH($B2,$A$1)))
. ... ...
10 abc, 1234 =NOT(ISERR(SEARCH($B10,$A$1)))
Which returns TRUE in cell C1, FALSE in cell C2 and TRUE in cell C10.
post scriptum : Taking a pick at bioschaf's comment may help you to generalize the concept.
Example 2
Checking whether the string value of each cell of column B is CONTAINED in the string value in column A's adjacent cell
Or using your example.
A B C
1 abc | cde abc =NOT(ISERR(SEARCH($B1,$A1)))
2 cde | bsd xxx =NOT(ISERR(SEARCH($B2,$A2)))
3 aaa | abc bsd =NOT(ISERR(SEARCH($B3,$A3)))
Example 3
Checking whether each column A's value is CONTAINED somewhere in column B's range $B$1:$B$11, using array formula
A B C
1 abc abc | cde =NOT(NOT(SUM(--NOT(ISERR(SEARCH($A1,$B$1:$B$11))))))
. ... ... ...
1000 aaa =NOT(NOT(SUM(--NOT(ISERR(SEARCH($A1000,$B$1:$B$11))))))
From which you can drop the NOT(NOT(...)) part so as to see the number of occurence rather than turning it into boolean values.
Example 4
Checking whether each column B's value CONTAINS at least one of the string value in column D's range $D$2:$D$5, using array formula
Using data you give in comment. And showing them in the column you also mention in comment, it follows that we have
B C D
1
2 hardware|information services|information technology hardware
3 hardware mobile
4 apps|mobile 3d
5 computer
Thus, if we want to check if each value in column B contains a word written somewhere in range D2:D5, what we can do is (say in column E):
E
1
2 =NOT(NOT(SUM(--NOT(ISERR(SEARCH($D$2:$D$5,$B2))))))
4 =NOT(NOT(SUM(--NOT(ISERR(SEARCH($D$2:$D$5,$B3))))))
3 =NOT(NOT(SUM(--NOT(ISERR(SEARCH($D$2:$D$5,$B4))))))
5
Where each of the above formula has to be validated as MATRIX-FORMULA by pressing CTRL+SHIFT+ENTER. Doing so will render :
E
1
2 TRUE
4 TRUE
3 TRUE
5
In E2 we have TRUE since hardware|information services|information technology contains the word hardware, actually located at D2.
In E3 we have TRUE since hardware contains (exactly) the word hardware, actually located at D2.
In E4 we have TRUE since apps|mobile contains the word mobile, actually located at D3

Related

How do I split a row of text into different columns according to number of characters using a macro in Microsoft Excel?

I want to know if I can use a macro in Excel to separate data in a single column into different colums according to number of characters. For example, what I have is this in column A
A
AB
ABC
1A
564
8
What I need is this, in colums A, B and C
A AB ABC
8 1A 564
Thanks.
Use the following formula in a new column B next to Column A:
=IFERROR(INDEX($A$1:$A$6,SMALL(IF(LEN($A$1:$A$6)=1,ROW($A$1:$A$6),99999),ROW()),1),"")
Array Formula press Ctrl+Shift+Enter at the same time
and drag it down, it will write the Values of B whose Length is 1, and when it gives empty it means no more Values with Length 1
Small will find the Cell which length is 1 (Row()=1, 1st cell which length=1, Row()=2, 2nd cell which length =1 ...)
If will return all the rows for the corresponding condition
Index will return the Cell
Iferror return empty "" if no more match
For the second column write 2 instead of 1 in LEN($A$1:$A$6)=2
=IFERROR(INDEX($A$1:$A$6,SMALL(IF(LEN($A$1:$A$6)=2,ROW($A$1:$A$6),99999),ROW()),1),"")
For the third column write 3 in LEN($A$1:$A$6)=3
=IFERROR(INDEX($A$1:$A$6,SMALL(IF(LEN($A$1:$A$6)=3,ROW($A$1:$A$6),99999),ROW()),1),"")

Excel - Match Value and Get Value of Other Column

I am trying to match 2 values on a table and if match, display the value from other column. Example is as below,
A B C D E F
ABC 1 WWE 5 output (1 FROM ABC) output (10 FROM ABC)
GHI 2 XYY 1
XXY 3 ABC 10
May I know how to do it? Can it be done in Excel
Use an INDEX/MATCH formula, for example in column E:
=INDEX(B:B,MATCH($A1,A:A,0))
And in column F:
=INDEX(D:D,MATCH($A1,C:C,0))
I'd usually wrap these in an IFERROR(,"") function to tidy up any errors. These formulas are based on you searching for the value in column A each time, if you want to search for a string instead simply replace $A1 with "ABC".

Find duplicates with a suffix in excel and keep results

I have a spreadsheet with a list of items in one column (A) and in column C shows the total sold. I'm trying to find all the items within column A.
The issue is, some items are the same, only they have a suffix, mostly separated by a -. The values in column C would be different as well.
Example:
ABC = 5
ABC-123 = 3
ABC-543 = 2
I'm looking to identify only 123 and then combine all the values, so that it will show ABC and 10 as the total.
I've looked around how to remove the duplicate suffix, but have so far failed to find a method when trying to add the total values.
Many thanks
do you mean the data you have looks like this:
column A column B column C
ABC 5
ABC-123 3
ABC-543 2
if so, you can select column A then go to data then text to columns then delimited select other by putting - sign, next and finish.
result must be:
column A column B column C
ABC 5
ABC 123 3
ABC 543 2
then you can =sumifs(C:C;A:A;"ABC") (keep in mind that column B must be empty)
if you have ABC-123 = 3 in the same cell as a text, then you can do:
=IF(SEARCH("ABC";F3);RIGHT(F3;LEN(F3)-FIND("=";F3)-1);"")
where F3 is equal to ABC-123 = 3 The formula above searches fo ABC and gives you a value after = sign, no matter how long this value is. If there is no ABC it will return an error.
if there is no need to look for ABC then just use:
=RIGHT(F3;LEN(F3)-FIND("=";F3)-1)
I hope this helps. I cannot comment, so ask if you have questions.
Best - AB

Excel matching multiple cells for duplicates

I need to populate a cell where the result is either valid or an error based on the following criteria. I'm not sure if using Match, Lookup formulas will work for this problem.
Given
A B C
+-----------+-----------+----------
1 | IntRef | Value | Result
2 |-----------|-----------+----------
3 | r01 | Value 123 | Success (because B4 matches B3)
4 | r01 | Value 123 | Success (because B3 matches B4)
5 | r02 | Value ABC | Failed (because B6 differs from B5)
6 | r02 | Value XYZ | Failed (because B5 differs from B6)
Success Criteria
Scan each IntRef (A) column for all duplicate keys. Where they match
on a row check the Value column (B). Where all matching cells have
the same value set their result cell (C) to Success.
Failed Criteria
Scan each IntRef (A) column for all duplicate keys. Where they match
on a row check the Value column (B). Where all matching cells have a
different value set their result cell (C) to Failed.
I am sure there is a formula that can be entered into each cell of column C which will do a lookup for each IntRef cross referencing the contents of column B where the match occurs. This is going beyond Excel formula knowledge.
Is it possible to create and help formulate the calculation of the success/failed criteria (Column C)?
This appears to do the trick...
{=IF(COUNT(IF($B$3:$B$6=B3,IF($C$3:$C$6=C3,1)))=COUNTIF($B$3:$B$6,B3),"Success","Failed")}
Note that that's an array lookup formula (meaning you need to hit Ctrl+Shift+Enter when entering it).
This formula basically counts the number of times the A and B column values appear together and compares this to the number of times the A column value appears. If the two counts match, you have success.
Try this formula:
=IF(SUMPRODUCT(IF(A2=A$2:A$9,1,0),IF(B2=B$2:B$9,1,0))>1,"Success","Fail")
Assuming you have your data like this:
Formula is entered as Array Formula in C2 by pressing Ctrl+Shift+Enter.
Then just copy on the remaining cells.
I just added and changed the position of some data for testing.
Hope this works for you. Change the Range to suit your data size.

Excel Find Nth Instance of Multiple Criteria

I have 3 columns of data. Col A contains Names, Col B contains a client ID, Col C contains a date.
I'm trying to figure out how to write a formula that will find the top 2 and top 3 instances of a specific Name in Col A and client ID in Col B and return the value in Col C.
Trying to avoid using VBA, but not sure if this is doable.
So for example data looks like this and I would want to return that Sam dealt with Client ABC the 2nd time around on 12/16.
Sam ABC 12/3
Adam XYZ 12/5
John DEF 12/9
Sam ABC 12/16
Adam HIJ 12/18
Assuming
your headers are in A1:C1
your data starts from A3 (yes, not A2)
You enter the name in G2 & Client ID in G3 & you want the list of
dates starting from G5
Enter these formula/values:
A2: =G2
B2: =G3
C2: =0
G5:
=IFERROR(INDEX(($A$2:$A$500=$G$2)*($B$2:$B$500=$G$3)*($C$2:C$500),MATCH(0,COUNTIF($G$4:G4,($A$2:$A$500=$G$2)*($B$2:$B$500=$G$3)*($C$2:C$500)),0)),"End")
(Formula in G5 is an array formula; confirm this with Ctrl+Shift+Enter)
Drag the formula in G5 down until you see 'End'
Value in cell G5 will always be 0 or '1/0' based on your formatting.
The list of dates corresponding to the name & client ID combination will start from G6.
Let me see if I understood your need. Correct me if I'm wrong.
You want to be able to inform a Name and a Client ID and have Excel tell you the last 3 occurrences of that combination?
By "top 2 and top 3 instances of a specific name" I'm assuming you mean the top 2 and 3 dates found for that specific name and ID.
If so, try this:
Supposing you have your example data table starting at Cell A1 and ending at Cell C6 (including column headers) and that you'll enter the name in F1 and Client ID on F2
A B C
1 Name Client ID Date
2 Sam ABC 12/3
3 Adam XYZ 12/5
4 John DEF 12/9
5 Sam ABC 12/16
6 Adam HIJ 12/18
Type this formula where you want to return the date of the last occurrence:
=IFERROR(LARGE(IF($A$2:$A$6=$F$1,IF($B$2:$B$6=$F$2,$C$2:$C$6)),1),"-")
This should be entered as an Array Formula, so don't forget to press CTRL + SHIFT + ENTER or it'll not work.
To bring the 2nd last occurrence on another cell, just copy and paste the formula and change the number 1 to 2 (as indicated below):
=IFERROR(LARGE(IF($A$2:$A$6=$F$1,IF($B$2:$B$6=$F$2,$C$2:$C$6)),2),"-")
If you typed 'Sam' on F1 and 'ABC' on F2, this formula would return '12/16' as the last occurrence, '12/3' as the 2nd last occurrence and a dash (-) as the 3rd last occurrence, since there isn't one.
Of course, you'll have to adjust the ranges and other cell references accordingly in your real data set.
Hope this helps.

Resources