Forum Discussion
I need help writing a formula please
Riny_van_Eekelen Actually, It didn't work.
- Riny_van_EekelenApr 28, 2020Platinum Contributor
animaltraceminerals Can you show the error? Upload the workbook or a screenshot that shows the formula and the result.
- animaltracemineralsApr 28, 2020Copper Contributor
=A5-B5-C5-D5*(E5=0)
gives me a return of "#VALUE!"But I found another thread with a similar question. This was one of the responses given.
=IF(A2>0,B2-C2,A2)
With this explanation:
"The above formula says:
IF cell A2 greater than 0, then subtract cell C2 from B2 and return the result.
Otherwise, return the value of cell A2 as it is."
So I tweaked it to work for what I needed and it worked.
=IF(E5=0,A5-B5-C5-D5,A5-B5-C5)
Using the previous explanation format,
If Cell E5 equals 0, then subtract cells B5, C5 and D5 from A5 and return the result. Otherwise, subtract only cells B5 and C5 from A5.
- SergeiBaklanApr 28, 2020Diamond Contributor
It's interesting how did you receive #VALUE! in first formula, perhaps you may share sample file?
By the way, you may simplify second formula
=A5-B5-C5-IF(E5=0,D5,0)All mentioned in the thread formulas are equivalent.
- SergeiBaklanApr 28, 2020Diamond Contributor
- Riny_van_EekelenApr 28, 2020Platinum Contributor
- SergeiBaklan Perhaps I indeed missed the A5 at the beginning. Wasn't entirely sure how to interpret the question. I read is so that the result would be in A5.