set a range of values to zero using if - excel

I want to do this:
A | B
===================
'blank' | 1
12 | 4
'blank' | 2
13 | 'blank'
I want to check B column and if there is a number there ( any number ) ,then fill the corresponding A cell (but only blank(empty) A cells ) with zero value.
I am trying something like this:
=IF( ISNUMBER(B1:B4) AND ( IF( NOT(ISNUMBER(A1:A4) ) ) ); (A1:A4 = 0);"" )
but it doesn't work.( I have set to the else statement above the "" )

If you are happy to write formula in new column then use this formula in column C for every cell C1=IF(AND(ISNUMBER(B1),A1=""),0,A1) then drag this formula for C2, C3, C4 etc.,.
my example

Related

How to convert this condition to an excel function ..?

Please, I need to write this condition in excel as a function :
if( A1 = 2 AND A2= 3 ) then { A3 will equal 10}
else if( A1 = 4 AND A2= 5 ) then { A3 will equal 20}
else if ( A1 = 6 AND A2= 7 ) then { A3 will equal 30}
A1, A2, A3 are the excel cells
thanks a lot in advance
Using some boolean logic:
=((a1=2)*(a2=3)*10)+((a1=4)*(a2=5)*20)+((a1=6)*(a2=7)*30)
Put the formula in A3:
=IF(AND(A1=2,A2=3),10,IF(AND(A1=4,A2=5),20,IF(AND(A1=6,A2=7,30,"NOT ANY OF THE CHOICES")))
As a literal interpretation, this formula matches what you're looking for:
=IF(AND(A1=2,A2=3),10,IF(AND(A1=4,A2=5),20,IF(AND(A1=6,A2=7),30,"invalid values")))
However, using a lookup table might be better, like so:
The lookup table is in columns E:G, and then the formula in cell A3 is (adjust the table ranges as necessary to account for all value combinations):
=INDEX($G$2:$G$4,MATCH(A1&A2,INDEX($E$2:$E$4&$F$2:$F$4,),0))

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

How to prevent my formula from skipping the cell when i insert new row

here is my sample
=IF(C4="R",E4,0)+IF(C5="R",E5,0)+IF(C6="R",E6,0)+IF(C7="R",E7,0).........
then if i insert new row between C4 to C5, my formula skips from C4 to C6
Here:
=IF(C4="R",E4,0)+IF(C6="R",E6,0)+IF(C7="R",E7,0)........
. | C | D | E
4 | "R" | ... | 14
5 | "T" | ... | 5
6 | "R" | ... | 6
TOTAL "R" = 20
TOTAL "T" = 5
Column C is drop down list each row you can select: "R", "T", "K".....
hoping some people help me. Thanks You very much..
i cannot post image coz it needs 10 reputation...
Are you able to post the Excel sheet with a little more detail on what your trying to achieve...meanwhile if your inserting rows but always want the SUM to be based on C4 then change to $C$4 etc adding the $ Char will lock the sum in place
if you send the sheet it maybe wiser you use a helper column with vLookup or Sumifs..
=SUMIF(C4:C6,A7,E4:E6)
C4:C6 is category range
A7 CELL where i make a reference for total of "R"
E4:E6 is the value of each category.
Thanks AXeL Richter!

Excel: Given a cell in column B as input, how could I find out the lowest cell of A which B > A?

I have an excel sheet, which value of column A >= B in the same row.
I would like to know given a cell in column B, how could I find out the lowest cell of A which B > A? (It should return a cell address but not the value)
For example, the following shows cells from A1 to B7 in a sheet:
A B
------
1 | 1 1
2 | 3 2
3 | 5 3
4 | 7 4
5 | 9 5
6 | 10 6
7 | 15 10
Now I would like to input B6, then it should return A3 (since 6 > 5)
Another example, if I input B7, then it should return A5 (since 10 > 9)
Is there any approach (or similar approach) by using excel formula? Or should I use other methods?
If your input value is in cell E1, and your return value is in cell E2 (as shown in below image), then you can use this formula in cell E2:
=IF(E1="","",INDEX(A1:A7,MAX(1,MATCH(TRUE,INDEX(A1:A7>=E1,),0)-1)))
Input Cell E1 (enter the address from column B here)
F1: =ADDRESS(LOOKUP(2,1/(INDIRECT(E1)>ColA),ROW(ColA)),1,4)
Given your data, if you enter B6 in E1, A3 will show in F1

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.

Resources