If column B cell value contains A cell value - excel

I have two columns A and B in excel and I want third column output to be like show below
A B C
-------------------
a | sd | a.com
d | a.com |
f | g.in |
g | ad | g.in
B column has 'a.com'which contains 'a.' so C column it displays a.com
.B column doesnt have which contains 'd.' so column cell is empty and so on..

Put the following formula in column C:
=IFERROR(INDEX($B$1:$B$4,MATCH(A1,LEFT($B$1:$B$4,SEARCH(".",$B$1:$B$4)-1),0)),"")
It is an array formula, so press Ctrl-Shift-Enter instead of Enter when entering it.

Try this formula in C1 copied down
=IFERROR(VLOOKUP(A1&".*",B$1:B$4,1,0),"")
IFERROR function only works in Excel 2007 or later - for earlier excel versions try
=LOOKUP("zzz",IF({1,0},"",VLOOKUP(A1&".*",B$1:B$4,1,0)))

Related

How to combine the contents of two cells if a another cell contains specific characters/strings or parts thereof

The issue:
I have cells containing strings, example:
Cell A | Cell B | Cell C | Cell D | Cell E | .....
1234 256 | 5424H-84 | 47-1223-7z-334| TARGET CELL | 12 fw e | .....
What formula do I need to look at the contents of Cell C for the characters "7z" or even "23" or "z-3", if present then to combine cell A and Cell B in to Cell D?
I've tried many things that I can think of and yet either get 0 or blank lines...
Try:
=IF(IFERROR(SEARCH("7z",C1,1),-1)>0,CONCATENATE(A1,B1))

Index only cells in a column from another sheet if another cell in same row has a value greater than 0

So I have an example below of what I'm wanting to do.
Basically I need to Index Column B from Sheet 1 into Sheet 2 BUT ONLY if the values in Column W in Sheet 1 are greater than 0. If it's not then I don't want it to be included in. The only column to Index is B starting from row 5 to say 100. Same for Column W.
I was trying to do it myself as I found This which is very similar as what I'm wanting to do but I couldn't figure it out.
Sheet 1
Row# Column B | Column(s)… | Column W
=================================
5) Thing 1 | | 0
6) Thing 2 | | 3
7) Thing 3 | | 0
8) Thing 4 | | 1
Sheet 2
Row# Column B | Column C | Column D
=================================
5) Thing 2 | 3 |
6) Thing 4 | 1 |
7) | |
8) | |
EDIT #3
You can use either SMALL, LARGE function to return the values from Column B on your Sheet1.
Presume you have given the following names:
Sheet1ColB: Sheet1!B5:B100
Sheet1ColW: Sheet1!W5:W100
Here is the formula to be put in Cell B5 on your Sheet2. Please note it is an array formula so you need to press Ctrl+Shift+Enter to confirm.
{=IFERROR(INDEX(Sheet1ColB,SMALL(IF((Sheet1ColW>0)*(LEN(Sheet1ColW)>0),ROW(Sheet1ColW)),ROW()-4)-4),"")}
or
{=IFERROR(INDEX(Sheet1ColB,LARGE(IF((Sheet1ColW>0)*(LEN(Sheet1ColW)>0),ROW(Sheet1ColW)),ROW()-4)-4),"")}
You can then use INDEX+MATCH to return the value from Column W on your Sheet1 in Column C on your Sheet2:
=IFERROR(INDEX(Sheet1ColW,MATCH(B5,Sheet1ColB,0)),"")
In the above screen-shot Solution 2 is using AGGREGATE which follows the same logic as SMALL/LARGE.
As you can see the sample data has taken into account duplicated values in Sheet 1 Col W, blank cells in both Column W and Column B on Sheet1, and blank cells, negative value or 0 value in Column B only on Sheet1.
Cheers :)
Use AGGREGATE() formula to filter based on condition.
=IFERROR(INDEX($A$5:$A$8,AGGREGATE(15,6,(ROW($A$5:$A$8)-ROW($A$4))/($B$5:$B$8>0),ROW(1:1))),"")

Using SUMIF on a range of columns or SUMPRODUCT to ignore text items

I have a range with various text and numbers in them. I wish to total the numbers based on the identifying first column.
I have tried
=SUMIF(A1:A20,"John",B1:E20)
which only returns the first columns number. I've also tried
=SUMPRODUCT((A1:A20="John")*(B1:E20))
but as there is text in column C, it returns #VALUE!.
A | B | C | D | E
John | 5 | Wine | 2 | 7
Sean | 6 | Beer | 5 | 2
I want all of the numeric values in columns B-E to be totalled together when "John" is in column A
Here is an array formula solution - use Ctrl, Shift and Enter to confirm:
=SUM(IF(A1:A20="John",IF(ISNUMBER(B1:E20),B1:E20)))
If you just want to exclude column C you could use this non-array formula:
=SUMPRODUCT((A1:A20="John")*(B1:B20))+SUMPRODUCT((A1:A20="John")*(D1:E20))
Alternatively, perhaps move C so it's not in the middle of your numbers.
Try this formula:
=IF(A1="John", SUMPRODUCT(--(ISNUMBER(B1:E1)),B1:E1), "")
and drag down to get sum on each row.

Search for word and add additional word to it and together copy to new row

I need small help. My problem is:
In sheet A under column A and B I have following:
Column A | Column B
----------------------|-------------------
New Orleans, Buffalo | Miami, Atlanta
etc | etc
. | .
. | .
I need formula to compare this words with Column C full names
Column C
New Orleans Saints
Miami Doplhins
etc
.
.
And Paste them to lets say Sheet 2 under column A and B as full name
Column A | Column B
--------------------|-------------------
New Orleans Saints | Miami Dolphins
etc | etc
. | .
. | .
Assuming your data is consistent i.e. Column A and Column B are in format xxx, yyy and you want to search for xxx in Column C, then as per image below enter the following formula in Cell E2
=IFERROR(INDEX($C$2:$C$50,MATCH(LEFT(A2,(FIND(",",A2,1)-1))&"*",$C$2:$C$50,0)),"")
Drag/Copy this formula to Column F and down as required. Change range as per your data.
Or if you want result in Sheet2 then enter following formula in Cell A2 of Sheet2
=IFERROR(INDEX(Sheet1!$C$2:$C$10,MATCH(LEFT(Sheet1!A2,(FIND(",",Sheet1!A2,1)-1))&"*",Sheet1!$C$2:$C$50,0)),"")
Drag/Copy this formula in Cell B2 and down as required. Change range as per your data.

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.

Resources