Excel skip blank or 0-valued cells - excel

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.

Related

Excel Formula to compare single cell value with the whole column and return the value for a particular row where match found

I need to compare the B2 Cell value (6012469) with Column A i.e. cell A2 to A10 and return the b2 cell value (6012469) in column C where the value matches i.e. cell C5,C7, C9 AND C10 and NA in remaining cells where the value is not matched.
I have around 15000 rows of data is column A and need to automate the process.
I have attached the sample image for reference.
[1]: https://i.stack.imgur.com/DvzC3.png
Select any cell inside your data range in Column A. Go to your ribbon, click Home > Format as Table. It doesn't matter what colour scheme you choose.
Make sure that all your data in Col A plus Cols B & C are included in the table.
Then, in any cell of your table in Col C (e.g. in C2), paste this formula:
=IF(ISNUMBER(SEARCH($B$2,[#[Column A]])),$B$2,"")
Excel should automatically populate all of your Col C in the table with this formula. (If it doesn't, then you should see a little clickable prompt next to the cell asking if you want to overwrite all the other Col C cells with this formula.)
The table with the Col C formulas would look something like this:
Note: Of course, you could achieve something very similar without using a structured table, but not as conveniently as this because you would have to copy the formulas down to the other approx. 15000 rows. Even the Fill Down feature is not as convenient.
ADDITIONAL: a different formula in response to the asker's request that each cell in Column C match any of multiple values in Column B --
=IFERROR(INDEX($B$2:$B$4,MATCH(TRUE,ISNUMBER(SEARCH($B$2:$B$4,A2)),0)),"")
NOTE: if more than one Column B value matches a Column A cell, Column C will display Column B's topmost match

Comparing two columns and printing out the difference?

I have two big columns that I'm comparing in Excel. I want to print out the values that column A has from Column B.
This is what I've tried: =ISNA(MATCH(A3,$A$:$D$28309,0))
Column A Column B Column C
A B B
B C C
C E
D E
A E
If one has the dynamic array formula FILTER:
=FILTER(A1:A5,ISNUMBER(MATCH(A1:A5,B:B,0)))
If not then INDEX(AGGREGATE()). Put this in the first cell and copy down:
=IFERROR(INDEX(A:A,AGGREGATE(15,7,ROW(A1:A5)/ISNUMBER(MATCH(A1:A5,B:B,0)),ROW(ZZ1))),"")
Assuming your original range is A1:B6 As you drag this formula down column C it will list all of the common values in the order of the first column then produce a #NUM! error when it runs out of matches. You can use an IFERROR formula to change the result to something else in those cases.
The size of the column don't need to match either.
=INDEX($A$2:$A$6, SMALL(IF(COUNTIF($B$2:$B$6, $A$2:$A$6), MATCH(ROW($A$2:$A$6),ROW($A$2:$A$6)), ""), ROWS($A$1:A1)))
Make sure to hit CTRL + Shift + Enter as this is an array formula.

excel: list all values of a column of a range based on a condition

I have a range in a Excel Sheet table that contains 2 columns like A and B.
I want to list in another column all values from column A if the corresponding value in column B is not null.
I know a way to do it, but it produces a lot of "empty raws" like in column C
=if(B<>"";A;"")
I would like to do it in a compact way, with no "empty raws" like in column D
Here is an example for data down to row #19. In C1 enter the array formula:
=IFERROR(INDEX($A$1:$A$19,SMALL(IF($B$1:$B$19<>"",ROW($B$1:$B$19)),ROW(1:1))),"")
and copy downwards. (You may need to use semi-colons in place of commas)
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.

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.

Formula to copy Column A to Column B without blanks and sorted?

I have the following column, A
C
R
H
Z
T
I would like a formula that automatically copies the data from A to B so that the data has no empty elements and it is sorted.
Column B should then look like:
C
H
R
T
Z
After that, if I were to add an element such as F to column A, such as:
C
R
H
Z
F
T
Column A would automatically update as:
C
F
H
R
T
Z
How can this be done with formulas (non-VBA code)? I'd like it to happen automatically (meaning i don't have to keep going to filter, sort every time a new piece of data is added to column A)
Thanks
You will need to create a helper column, with this array formula:
=SUMPRODUCT(IFERROR(CODE(UPPER(MID(A1,ROW(INDIRECT("1:"& MAX(LEN($A$1:$A$9)))),1))),10)*100^(MAX(LEN($A$1:$A$9))-ROW(INDIRECT("1:"& MAX(LEN($A$1:$A$9))))))
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. IF done correctly then Excel will put {} around the formula.
Then you would use this formula to sort and filter:
=IFERROR(INDEX(A:A,AGGREGATE(15,6,ROW($B$1:$B$9)/((AGGREGATE(15,6,$B$1:$B$9/($A$1:$A$9<>""),ROW(1:1))=$B$1:$B$9)*($A$1:$A$9<>"")),1)),"")
One note, this may implode with large strings.
You can use this array formula and drag it down, A1 your first Data in column A, in B1 write helper column to sort values:
=IF(COUNTIF($A$1:$A$21,"<="&A1)>0,COUNTIF($A$1:$A$21,"<="&A1),999999999)
and drag it down
In C1 write =IF(INDEX(A:A,MATCH(SMALL(IF(B:B<>0,B:B,999999999),ROW(A1)),B:B,0))=0,"",INDEX(A:A,MATCH(SMALL(IF(B:B<>0,B:B,999999999),ROW(A1)),B:B,0)))
Press Ctrl+ Shift+Enter at the same time
IF will check for non empty cells and return the corresponding row
Small will find the upper non empty cell and move with the row,in row1 Small(,1)
in row10 small(,10)
INDEX(A:A) is your initial column
IFERROR in case the cells in A are empty it will return "" empty in column B
You have to drag the formula down even if you have empty cells in A, in that case when you write in the cells the formula will autofill in column B
9999999 it will not affect the small function
Without helper column you will need to sort the Data or use it unsorted but remove blank
You can use in B1:
=IFERROR(INDEX(A:A,SMALL(IF(A:A<>"",ROW(A:A),999999999),ROW(A1))),"")
Also array formula
Press Ctrl+ Shift+Enter at the same time
and drag it down
Another idea assuming your column contains only single characters,
Formula in column B,
=IFERROR(CODE(A:A),"")
Formula in column C,
=IFERROR(CHAR(SMALL(B:B,ROW())),"")
When you enter the formula you should not be doing it cell by cell or by dragging it. Select the entire column, paste the formula in formula box and press CTRL + ENTER. This will apply the formula for all cells in that column.

Resources