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

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))

Related

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))),"")

I have a list of keywords and want to count the number of match keywords in each cells text from EXCEL File

I have 2 sheet in a excel file. one is a Dictionary sheet and 2nd is a sheet containing a column of text. I want to match the dictionary keywords columns one by one and then the number of match keywords counts in each cell of the text column.
I have tried these formulas:
=(LEN(B2)-LEN(SUBSTITUTE(B2,Sheet1!A:A,"")))/LEN(Sheet1!A:A)
in this B2 is the first (start) cell of the text column and Sheet1!A:A is the dictionary column of other sheet.
but by this i get zero as a result
=(LEN(B2)-LEN(SUBSTITUTE(B2,Sheet1!A:A,"")))/LEN(Sheet1!A:A)
The result will be like this:
Text number_of_keyword_match | number_of_keyword_match using DIC col 2 | ........
using DIC col 1
1 any Text or sentence/sentences e.g match "3"
2 7
3 0
4 15
5 .................................................
7 .....................................................
.......................................................
..................................continue up to 2815 rows....
Assuming your text input looks like this:
| A |
-+----------------------+
1|apple apple beat beat |
2|apple beat beat carrot|
3|carrot apple apple |
and your dictionary looks like this:
| A | B |
-+-------+-------+
1|apple |beat |
2|beat |carrot |
3| | |
This formula will give you the count per word per cell of text
=(LEN(text!A1)-LEN(SUBSTITUTE(text!A1,dictionary!A1,"")))/LEN(dictionary!A1)
(In this example 2)
If I understand correctly, your expected output would be extra columns in the text sheet where each cell contains the sum of counts of each word in the corresponding column in dictionary, right? For example:
| A | B | C |
-+----------------------+---+---+
1|apple apple beat beat | 4 | 2 |
2|apple beat beat carrot| 3 | 3 |
3|carrot apple apple | 2 | 1 |
You can use array formulas to do this, starting with this one in cell B1:
=SUM(IFERROR((LEN(text!$A1)-LEN(SUBSTITUTE(text!$A1;dictionary!A:A;"")))/LEN(dictionary!A:A);0))
But instead of pressing Enter after pasting it in, press Ctrl+Shift+Enter to run it as an array formula. Then drag this formula down and to the right to get all the counts you want.
I would consider countif(), as an example:
=COUNTIF(Sheet2!A1:A10,Sheet1!A1)
which assumes your list starts in cell A1 on sheet1 and your text in cell a1 on sheet2.
To drag the formula as I showed it, without the data range moving you need :
=COUNTIF(Sheet2!A$1:A$10,Sheet1!A1)
if you put $ before the letters, then the columns don't move.

How to do multi-column match in Excel

I have a spreadsheet that looks like this:
A B C D
------------------------------------
1 | Yes | No | | | |
2 | 1 | 1 | 0 | 1 | 0 |
------------------------------------
------------------------------------
12| Yes | No | | Yes | Yes |
13| Yes | Yes | No | No | |
14| Yes | No | | No | Yes |
15| No | Yes | No | No | |
...
I want to fill the cells in Row 2 with a 1 or 0 depending on several criteria. The value should be 1 if all of the following are met (using cell D2 as a reference):
All previous values in Row 1 should match at least one entry in the table starting at D12. For cell D2, this means A1:C1 should exactly match columns A:C in at least one row of the table.
For any of the matching rows from #1, there should be a non-empty value in the same column as the cell being evaluated. So cell D2 would look for a non-empty value in Column D of any rows that match the criteria in #1.
If either of these conditions fails, the cell value should be 0. In Cell D2 we have a value of 1 because the algorithm finds a match in rows 12 and 14 and a non-empty cell in D12 and D14.
I'll need to be able to apply this dynamically across several columns so I'm trying to avoid writing a column-specific function. I realize I could probably write a UDF to perform this, but I wanted to avoid going that route if possible.
Because this was a challenge I had a go at it and came up with
=SIGN(SUM(--(MMULT(($A1:A1=$A12:A15)*(B12:B15<>""),TRANSPOSE(COLUMN($A12:A15)^0))=COLUMNS($A1:A1))))
to be entered in B2 and pulled across. This has to be entered as an array formula using CtrlShiftEnter
A2 I think is just
=sign(counta(a12:a15))
because it will be 1 unless the whole column is empty.
I'm not sure there's a complete answer to your problem as stated without a UDF, but I'd question the method a bit and say "why complicate with 'AND this column isn't blank (but could be any other value)?"
Why not just look for a row match from that field backward? Seems to me it would just shift things by a column, and in fact, this is exactly what you're doing in A2 anyway, since there's nothing before A. So matching on duplicate rows for example, D2 would contain basically the same information as your example has in C2.
To look for duplicates across fields, you could use something like this formula that would go in C2: =IF(SUMPRODUCT((A3:A15=A1)*1,(B3:B15=B1)*1,(C3:C15=C1)*1)>1,1,0)
In D2, you'd copy that formula and add (D3:D15=D1)*1, etc.

In Excel, add 1 if not number, or else add the number

In excel, how do I write a formula that does the following:
In a certain cell range, if the cell contains a non-numeric entry, add one, or else add the number the cell contains.
for example
4
xyz
def
bc
2
0
=9
or
1
ab
cd
2
af
=6
Contents of the data A1:A6
4
xyz
x
2
y
0
Write the following formula in cell B1
=SUM(A1:A6)+(COUNTA(A1:A6)-COUNT(A1:A6))
I would use an array function:
{=SUM(IF(ISNUMBER(A1:F1);A1:F1;1))}
Enter by writing "=SUM(IF(ISNUMBER(A1:F1);A1:F1;1))" and pressing Ctrl+Shift+Enter.
A | B | C | D | E | F | G
--+---+---+---+---+---+---+---
1 | 4 | a | b | c | 2 | 0 | {=SUM(IF(ISNUMBER(A1:F1);A1:F1;1))}
What I would do is write a the formula
=ISERROR(Cell+0, 1)
next to each cell, and then sum across these cells.
What the formula does is it returns the value of the cell if the cell is a number, and it returns the number 1 if the operation "cell + 0" errors out (e.g. when the cell's value is not a number).
See the picture below for how i applied this to your first example.

If column B cell value contains A cell value

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)))

Resources