Need help with nested IF statement

leopardhawk

Well-known Member
Joined
May 31, 2007
Messages
611
Office Version
  1. 2016
Platform
  1. Windows
I have a formula that is working but I want to modify it ever so slightly. I believe I need a nested IF statement but I continue to get the #VALUE error. Here is the working formula:
Code:
=IF(COUNT(B16,B20)=2,SUM(B16+B20),"")
I would like the formula to return B16 on its own if it contains data... here is my modified formula (which returns the error):
Code:
=IF(COUNT(B16)=1,B16,""),IF(COUNT(B16,B20)=2,SUM(B16+B20),"")
Any suggestions are much appreciated. Thanks!
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
how about this:

=IF(OR(B16="",B16=0),"-",B16+B20)

To see where you're error is coming from use 'Evaluate Formula' on the 'Formula Auditing' tab of the Formula Ribbon - I use it a lot!

HTH
 
Upvote 0
When you nest IF formulas, the nested part goes in the FALSE clause (every IF has exactly 3 arguments, the condition, the TRUE clause, and the FALSE clause).
You have nested incorrectly, as you tried to do the nesting after the FALSE clause, instead of in the FALSE clause.

Also, SUM(B16+B20) is unnecessary and redundant.
If you just want to add those two numbers, all you need is B16+B20.
If you want to sum the range B16 through B20, then you would use SUM like this: SUM(B16:B20)
 
Upvote 0
Try this

=IF(COUNT(B16,B20)=2,SUM(B16,B20),IF(COUNT(B16)=1,B16,""))

I presume that you want the sum if both contain a number, otherwise B16 value if only B16 contains a number
 
Upvote 0
Solution
@pjmorris @Joe4 @Yongle I appreciate all three posts. PJ, I am still receiving the #VALUE if there is nothing in B20. Joe, I was trying your suggestion on my own when Yongle's came in and his works exactly as I need it to! Thanks to all three of you for your efforts. I learn as I go along here.
 
Upvote 0
You are welcome.
Glad we were able to help!
 
Upvote 0

Forum statistics

Threads
1,214,978
Messages
6,122,549
Members
449,089
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top