How to skip a blank cell and while concatenating in Excel - excel-formula

My cell values read as follows:
Column A1 Column B1 Column C1 Column D1 Column E1 Column F1
Blank Text 1 Text 2 Blank Text 3 Concatenate Col A to E
While concatenating this, I expect the values as below:
Column F1
Text 1
Text 2
Text 3
I use the formula below and I get:
=A1&CHAR(10)&B1&CHAR(10)&C1&CHAR(10)&D1&CHAR(10)&E1
Blank
Text 1
Text 2
Blank
Text 3
Can any one help me on this?

You can test the length of each cell before including it in your formula's results. Something like this:
=IF(LEN(A1)>0,A1&CHAR(10),"")&IF(LEN(B1)>0,B1&CHAR(10),"")&IF(LEN(C1)>0,C1&CHAR(10),"")&IF(LEN(D1)>0,D1&CHAR(10),"")&IF(LEN(E1)>0,E1,"")
This checks that each cell has a length greater than 0 before including it.
To break it down, the formula is 4 identical constructions and 1 similar construction. There are 4 of these:
IF(LEN([cell])>0,[cell]&CHAR(10),"")
which says: If the length of [cell] is greater than 0, then use the value of the cell and CHAR(10). If it is not greater than 0, then use an empty string ("").
The last section is the same thing, but without including the CHAR(10):
IF(LEN([cell]>0,[cell],"")
It might be easiest to see the full formula's construction in the following form:
=IF(LEN(A1)>0,A1&CHAR(10),"")
&IF(LEN(B1)>0,B1&CHAR(10),"")
&IF(LEN(C1)>0,C1&CHAR(10),"")
&IF(LEN(D1)>0,D1&CHAR(10),"")
&IF(LEN(E1)>0,E1,"")

Related

Test for a cell not being formulaically populated vs one with data sourced from a different cell

I have a spreadsheet that auto-populates column B to equal the cells in column A. Column C will be the cell in column A, one row down, but if the cell in column A of the same row and column A of the next row are the same, it wil be column A of two rows down. Using this formula: =IF(A5=A6,A7,A6).
Right now, it prints data in one of the cells when they only contain the formula. I dont understand why.The right column below, which has 2 indigo,
is an example of the problem, with 'empty' where the cells are not populated, they have a blank pick list.
.. A ....... B.... . C
2 red .... red . orange
3 orange orange yellow
4 yellow yellow green
5 green green blue
6 blue.. blue... 0
7 empty . 0.... indigo
8 empty .. 0 ....indigo
9 indigo indigo violet
.
I don't mind the 0 being displayed, but the 3rd column up, right cell, is printing indigo, when it shouldn't be. The columns above that work fine.
NOTE: The cell in column C, violet, has a slightly different formula, if the
first cell matches the cell below, it sets it to the first data cell in column c, otherwise to the next cell in column A =if(a8=a9,a2,a9)
What I need to see to reduce the risk of human error, is have either a zero, or
nothing displayed in the cell which is showing the first indigo in column c.
Your formula is working correctly. The IF function evaluates a condition and returns either the True or False statement depending on the evaluation. Your condition is evaluating A5=A6 i.e. current cell equals cell above.
Row 9 Blue and Empty are not equal so you get 0 as this is what the empty cell A10 returns
Row 10 Empty and Empty are equal so A12 returned which is indigo
Row 11 Empty and Indigo are not equal so A12 returned which is indigo.
Instead change your test conditions to handle blank cells try:
Column B (To get rid of zeroes)
=IF(A5="","",A5)
Column C
Try variations on the following:
=IF(OR(A5="",A6=""), "", IF(A5=A6,A7,A6))
This part: OR(A5="",A6="") is handling all combinations of blank comparisons i.e. current cell is blank, cell above is blank, both are blank.
Switch these out with ISBLANK function for empty cells:
Column B
=IF(ISBLANK(A5),"",A5)
Column C
=IF(OR(ISBLANK(A5),ISBLANK(A6)), "", IF(A5=A6,A7,A6))
If you want to handle blank/empty cases differently then consider also using other logic operators e.g. AND operator in a test with AND(ISBLANK(A5),ISBLANK(A6)) if only where both blank, for example. In the above example, the OR operator will cover this because I was catering for any occurrence of a blank/empty in current or cell above.

Searching for multiple keywords in excel

I have course listings with detailed description. I have 25 keywords in order to filter particular type of course. I want to count the number of courses with the description containing more than 3 keywords. Can anyone help me how to do it?
One way...
Say course descriptions are in column A with heading in A1 and descriptions below in A2, A3, etc. Then, next to the header in following columns, we'll assume C and on to the right here, type in the keywords. Then:
//copy these down and to the right
In cell C2: =IFERROR(IF(FIND(C$1,$A2)>0,1,0),0)
Now of these cells under C2 and on to the right will have a 1 if the keyword matches the heading above that cell, a 0 if not. Then, just sum the columns in row be:
// copy these down
In cell B2: =if(SUM(C2:AD2)>2,1,0)
This column B will now show a 1 beside each course with 3 occurrences or more, a 0 for any with less. Now, just sum this column B for the total number of courses:
=SUM(B:B)
Note, this counts occurrences of a string. Thus a search for "and" would return to in the entry "random and unusual." Just a warning...
Fill the Excel spreadsheet as follows:
Row 1:
A1: Description. Below there will be descriptions of your courses.
B1, C1, ... Z1 (next 25 cells) - Keywords to find in descriptions.
AA1: Sum. Below will be numbers of keywords found in each description.
Column 1:
A2, A3, ... - Course descriptions.
Row 2 - Formulas for course 1:
B2: Insert formula: IF(ISNUMBER(SEACH(B$1;$A2));1;0)
Note $ characters in the formula above: B$1 - fixed column (1)
and $A2 - fixed row. This is required to keep column / row fixed,
as the formula will be copied (description below).
Copy the above formula to cells C2:Z2.
This way you have in each cell either 1 if the keyword above
(in row 1) was found in course name (in column 1).
AA2 (sum column): Insert formula: SUM(B2:Z2). This way in column AA
you have the number of keywords (from row 1) found in
description (in column A).
Copy formulas from A2:AA2 to each following row with description filled.
Assuming that you have 100 such course descriptions, you have
till now filled:
Row 1 with header data.
Rows 2 to 101 with descriptions (column A) and formulas
(further columns).
Then, in cell AA102 (below the last sum) enter formula:
COUNTIF(AA2:AA101;">3") - count cells containing value more than 3.
This is the result you are looking for.
If you have more or less course descriptions, change the above
formula (and its location) accordingly.
And the last remark: I used non-English version of Excel and then
"manually" translated my native function names into English.
So in case of function name errors try to figure out what actual function
name should be.

Jump to the next non-empty cell and use lates value in the list

I have the following Excel spreadsheet:
A B Desired Result Column B
1 Product A 50 **50** **50**
2 Product B =IF(A2="","",B1) 50 50
3 =IF(A3="","",B2)
4 Prodcut C =IF(A4="","",B3) 50 **40**
5 =IF(A5="","",B4)
6 ="" =IF(A5="","",B5)
7 Product D =IF(A5="","",B6) 50 40
8 Product E =IF(A5="","",B7) 50 40
** Input of User
In Column A there is a list of different products. As you can see there can either be empty cells or cells with formula ="".
In Column B I want to achieve that the last value before the first empty cell or ="" cell applies to the other rows.
For example: If I enter a 50 in Cell B1 I want to achieve that this 50 appears next to every product and empty cells or ="" are ignored.
I can achieve this with the following formula:
=IF(A2="","",$B$1)
Now the problem is, that the user can also type a different number in another cell in Column B. For example he could type in a 40 in Cell B4.
In this case I want that the 40 applies to all other following rows instead of the 50 as you can see in the section "Desired Result Column B" in the example above.
How do I have to change my formula in Column B to achieve this?
Enter the following formula in Cell B2
=IF(A2<>"",INDEX($B$1:$B1,MAX(IF($B$1:$B1<>"",1,0)*ROW($B$1:$B1))),"")
Drag/Copy down as required.
This is an array formula so commit it by pressing Ctrl+Shift+Enter.
Try:
B2: =IF(A2="","",LOOKUP(2,1/LEN($A$1:A1),$B$1:B1))
With the addressing mode used in the LOOKUP formula, it will examine the rows up to the row before the lookup. If the column A value is not blank, lookup_vector will match the last non-blank cell in column A prior to the row containing the formula, and result_vector will return the value in the same row in column B.
It is rather critical that your user entries are restricted as you have described above.
If the user can make an entry in column B that does NOT correspond to an entry in column A, and you want that entry to be copied down, then use:
=IF(A2="","",LOOKUP(2,1/LEN($B$1:B1),$B$1:B1))
Also, note that the sequence will be upset if the user deletes an entry in column B, instead of replacing it with another number. The formulas below the deletion will interpret the deleted value as a zero.

Excel skip blank or 0-valued cells

I would like to have a formula that scans through one column of data, and should this column be non-zero, it registers the contents of a cell in another column, but the same row. I would also like it to trim out the blank cells. Is this possible in Excel 2007?
for example: I have,
column A
A
B
C
G
H
column B
1
2
blank
blank
8
If the criteria is a non-zero column B, we have the following output:
column N
A
B
H
The usual way to do something like this would be to use INDEX and SMALL in an array entered formula:
=IFERROR(INDEX(A:A,SMALL(IF(B:B<>0,ROW(B:B)),ROWS($B$1:B1))),"")
Put that in the first cell in column N and after typing the formula, don't press Enter. Instead, press Ctrl+Shift+Enter
And then you can drag it down.

COUNTIF how many times a value appears in a column, depending the content of a cells value

i am trying this =COUNTIF(M1:M1000001;" * A1 * ") but is not working.
I want to count how many times the column dispays the content of the cell A1. Note that the content of the cell will appear as a content
example:
0 A M
1 la trala
2 0 sela
3 0 copy
by these data, the result must be that the content of the cell A1 is appearing 2 times in the M column
When you are using quotes, you are taking the literal "A1", so that COUNTIF is looking for " A1 " in your cells. What you probably wanted is this:
=COUNTIF(M1:M1000001;"*"&A1&"*")
When you put A1 outside the quotes, excel will refer to the cell A1. But then, you need to concatenate this result with the asterisks so you can search through the whole text of the cell.
Check this
=COUNTIF($M$1:$M$100,"*"&A1&"*")

Resources