Apply formula on condition - excel

I'd like to add a condition to one of my Excel formulas. In Cell C1 I have a formula like this : = A1 +B1 but if cell A1 is empty but cell B1 does contain a value (or vice versa) I'd like cell C1 to stay empty.
Condition : Only apply formula if both cells contain any value.
(The formula I'm using in cell C1 calculates the difference between dates, and does this for a list of values, so it is applied on the whole range "C:C".)

Here you go
=IF(OR(A1="",B1=""),"",A1+B1)

=IF(SUM(IF(A1="",0,1),IF(B1="",0,1))<2,"",A1+B1)

Related

Google Sheets or Excel: setting the value of a remote cell from a formula

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 have to cells, A1 and B1, I want to display the value of A1 or B1 when either cell have value entered

I have two cells, A1 and A2, I want to display the value of A1 or A2 in cell B1 when either cell have value entered. how do I create the formula for cell B1?
=TEXTJOIN(",",TRUE,A1:A2)
This formula will only return nonblank cells (because of the 'TRUE' argument). If both cells are nonblank, it will return both values seperated by a comma, (because of the '", "' argument)
Alternatively if you want to only return one cell even if both were occupied, you could prioritize A1 like this.
=IF(ISBLANK(A1),A2,A1)
As far as I can tell, the following should serve:
=A1&A2
where TEXTJOIN is not available.
Questions tagged with excel should be version-agnostic.

how to backcheck aganist cells and data validation list?

I've set cell A1 with data validation with list of possibilities: a,b,c,d
next I would need formula which will do this:
if a is chosen in A1 cell, set cell C1=b, C2=c, C3=d
if b is chosen in A1 cell, set cell C1=a, C2=c, C3=d
if c is chosen in A1 cell, set cell C1=a, C2=b, C3=d
if d is chosen in A1 cell, set cell C1=a, C2=b, C3=c
is there some handy formula for this purpose which I will place in cells C1, C2 and C3 which will backcheck with A1 and also between themselfs to avoid duplications?
google-spreadsheet
C1:
=FILTER({"a";"b";"c";"d"},{"a";"b";"c";"d"}<>A1)
The following array formula will do the job in Excel (select the range C1:C3 and use Ctrl+Shift+Enter to enter the formula):
=MID(REPLACE("abcd",MATCH(A1,{"a","b","c","d"},0),1,""),ROW(),1)
You haven't specified what you want the result to be if A1 contains neither of those values, but you may wish to wrap it in IFERROR().

Insert a value to a cell in excel using formula in another cell

I need to insert a value to a cell in excel using formula in another cell.
Say
A1 = "Test"
B1 = formula to insert A1 to C1
C1 = A1
Can I write a formula in B1 to insert value in C1?
I don't need any formulas in C1.
If Yes, What should be the formula?
If there it is next to the cell AND has no value in B2, it is possible, otherwise it is not.
Use Split()
Split(CONCATENATE("Text for B1#Sperator$$",A1),"#Sperator$$",FALSE)
It really depends.
EDIT
Out dated. Only works in google sheets.
Without using VBA or formulas in column C you can't achieve this.
A simple solution using formulas:
In cell C1, paste the following formula and drag it down:
=IF(B1=1;A1;"")
So if the content of cell B1 is equal to 1, your cell at column C will display the respective value of the same row at column A.

Excel "IF" function.

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.

Resources