I am attempting to compare the numerical value in one column with that in another. Then have another column populated depending on the results. I do not know how to write this due to limited experience with Excel. This is what I am attempting to do:
If B1 < C1 then D1 = C1
If B1 > C1 then D1 = B1
You should put your logic(formula) in the cell you want to give a custom behavior.
As I can see you want to put a dynamic value into column D cells (D1).
So, you should put a formula in cell D1 to behave as you want:
=IF(B1<C1,C1,B1) (sometimes you have to use ; instead of , depending on language)
It says:
If b1<c1 then put C1 into this cell otherwise B1
=IF( Logic, Case-true, Case-False )
In excel the IF operator receives 3 inputs separated by ; sign:
The logic condition in the first option
the result you want to use if condition is true
the result you want to use if condition is false
To use this formula in all lines of column D, just press the black little square in the right corner bottom of the cell and grab it until the line you want
Related
Is there a way to create a formula in one cell that will change the value in another cell based on some criteria, without scripting? Example: cell a1 contains a numerical value. cell b1 contains a value from a drop-down list, say, "YES,NO". If cell b1 is set to "YES" I want to remove (set to zero) the value in cell a1. What I'd like to do is have a formula in cell c1 that interrogates b1 and sets the value in a1 accordingly. Is the only way achieve this writing code and using setValue?
you cant remove it without a script. you can visually hide it in various ways. if the A1 is subject of further sum (as in your case per your comment) the sum formula can be always altered to reflect desired output. example:
if your formula is
=SUM(A1, C5, D22)
you can do
=SUM(IF(B1="YES", 0, A1), C5, D22)
Use the following on the cell you need the calculation (or zero) on:
=IF (B1="YES",0,SUM(A:A))
Using the given formula, you would do the SUM calculation for the whole Column A if the value on B1 is "YES", if not, then a 0 would be placed on the cell you put the formula on.
I am wondering if there is a simple way to count the number of rows after filtering a subset of columns by value considering multiple selections for a given column in an excel table object.
Let's say I have the following excel table:
A B C
a1 b1 c1
a2 b2 c1
a1 b2 c2
a2 b1 c2
a1 b3 c3
a3 b1 c3
saved in an excel table under the name: Table1 and I would like to find all rows that the column A has the value a1 or a2 and column B has the value: b1. The result should be 2.
I am able to do it using SUMPRODUCT function and converting the logical value into [0,1] using the -- operator:
= SUMPRODUCT(--(Table1[A]="a1"),--(Table1[B]="b1"))
+ SUMPRODUCT(--(Table1[A]="a2"),--(Table1[B]="b1"))
In my real example, I have more than three columns and at least one of them can satisfy multiple criteria so I am wondering if there is a way to do it with a less verbose syntax. For example, I was trying something like this, but it does not work:
= SUMPRODUCT(--(Table1[A]="a1|ab2"),--(Table1[B]="b1"))
or
=SUMPRODUCT(--(Table1[A]=OR("a1", "a2")), --(Table1[B]="b1"))
the OR function does not help, because it does not return an array result, and I cannot use the array formula in my real example because I would need to apply just for one column with more than one selection, but for the rest of the columns I am selecting it is just a single value.
It seems to be a good trick for representing in an excel formula a multiple filter criteria action, but the excel formula is very verbose when within a column it has to satisfy more than one condition, like in the above example.
Under my solution, it would something like this for counting rows in a Table where for each column we filter by only one value except for the first column A that we filter by two possible values:
= SUMPRODUCT(--(Table1[A]="a1"),--(Table1[B]="b1"),
--(Table1[C]="c1"), ...Table1[Z]="z1"))
+ SUMPRODUCT(--(Table1[A]="a2"),--(Table1[B]="b1"),
--(Table1[C]="c1"), ...Table1[Z]="z1"))
Try:
=SUMPRODUCT((Table1[A]="a1")+(Table1[A]="a2"),--(Table1[B]="b1"))
Since any given cell's cannot both be "a1" and "a2", the sum will be 1 if either is true and 0 if neither is true
I'm creating a spreadsheet that has dropdowns that have content based on more than one cell, and add different things according to those conditions. I've been searching for the past hour trying to find something online (here, Google, etc), and either I haven't been searching for the right thing, or no one's thought to try it before, but either way, here we go:
The point is that, in Data Validation, the references for named groups seem to be only singular, but I want to be able to add multiple named groups to a single drop-down list depending on what's available. For instance, one drop down box (D1) can have values based on two cells (A1, A2), and both are dropdowns themselves. If A1 and A2 both say that something should show in D1's list, I want both to show up (in an order specified by the order in which I check the cells). Is this even possible with Excel, and if so, how the heck do I do it?
Wow man this was really a challenge I enjoyed this one quite a bit! Sorry the first answer was not what you needed but this should do!
So first I set up my sheet as follows:
I then added the True and False conditions for Choice 1 & 2 using data validation
I then input formulas in Column H to create a new list based on the choices
=IF($A$2=TRUE,E2,"")
=IF($A$2=TRUE,E3,"")
=IF($A$2=TRUE,E4,"")
=IF($A$2=TRUE,E5,"")
=IF($A$2=TRUE,E6,"")
=IF($B$2=TRUE,F2,"")
=IF($B$2=TRUE,F3,"")
=IF($B$2=TRUE,F4,"")
=IF($B$2=TRUE,F5,"")
=IF($B$2=TRUE,F6,"")
So for the first 5 formulas if the choice is A2 is True then it will display the appropriate item from List 1 into the Dynamic List.
For the last 5 formulas if the choice is B2 is True then it will display the appropriate item from List 2 into the Dynamic List
For Example:
If A2 = True & B2 = False
If A2 = False & B2 = True
At this point I realized that the spaces in the dynamic list would be a problem so I had to create an ARRAY to remove the spaces. There are tons of examples online to do this but this was the simplest formula. (I can't explain ARRAY formulas I use them every once in awhile but don't fully understand them I am sorry about that)
In I2 I placed the following ARRAY formula (The cell above I2 must remain blank)
=INDEX($H$2:$H$11, MATCH(0, IF(ISBLANK($H$2:$H$11), 1, COUNTIF(I1:$I$1, $H$2:$H$11)), 0))
You then must press CTRL + SHIFT + ENTER after inputting the formula to make it an array formula
Then drag the formula down to I11 using autofill
Then in C2 I created a dynamic drop down using data validation and an OFFSET Formula to refer to the valid text items contained in the indexed list (The OFFSET formula is is explained here http://www.ozgrid.com/Excel/DynamicRanges.htm)
The formula is:
=OFFSET($I$2,0,0,MATCH("*",$I$2:$I$11,-1),1)
The OFFSET Formula is used in the source field of the Data Validation for C2
Now your list in C2 is dynamic based on the Choices in A2 and B2
For example:
A2 and B2 = False
A2 = True and B2 = False
A2 = True and B2 = True
A2 = False and B2 = True
There might be another way to do this with VBA (I am not that great with it) as well but for now this should do! Hope this solves your issue!
It is possible I was able to do this:
I made list of items in column D and E in this instance:
Column D contains the letters A,B,C,D
Column E contains E,G,H,I
The values can be what ever you need it to be.
I then made a drop down list in cell B1 using Data Validation -> List referencing the list in column D
I then made a drop down list in cell C1 using Data Validation -> List referencing the list in column E
I Then made a drop down list in cell A1 using Data Validation -> List referencing the drop down lists that are in B1 and C1
This dynamically changes drop down list in A1 based on the selected values in B1 and C1
In the image below I selected B and H which changed the list in cell A1 to have the options B and H.
If I want to only ask excel to calculate in a cell if TWO other cells have values in them, what is the code? I know that for it to calculate only if a single cell has a value is =if(A1=0,"",B1-B2)....but how do you add criteria that two cells have a value in them?
Example where A1 and B1 are 0:
=IF(AND(A1=0,B1=0),"",B1-B2)
With this you can verify witch cell has no value
=IF(B3="",IF(C3="","both EMPTY","B3 empty C3 with value"),IF(C3="","C3 empty B3 with value","both with value"))
You can also set cell = 0 on the comparison.
I want to accomplish a certain task in excel.
I want to practice 10 key skills.
I have typed numbers in column A(cells, A1,A2,A3,etc.). I want to retype them in column B. Then (if column B matches column A) would like to have the word "OK" appear in column c. Can write the simple IF statement for A1=B1. Do not know how to make the statement automatically apply to other cells(i.e if A2=B2, A3 =B3, etc).
Thanks. CD
In cell 'C1'
=If(A1=B1,"OK", "")
Now drag this cell down col C until your last row. Excel will auto increment A1 & B1 to A2 & B2 and so on... unless you use absolute referencing which is the dollar sign like this $A$1 for example.