Calculate if not blank and sum without errors

aiki100

Board Regular
Joined
Aug 16, 2016
Messages
102
Hello everyone - I was hoping to get a little help with this formula (in COL BE2), please:


=IF(AND($AP2="x",$AW2="L",I3>BC2),J3-AY2,IF(AND($AP2="x",$AW2="S",H3<BC2),AY2-J3,IF(AND($AP2="x",$AW2="L",I3<=BC2),BC2-AY2,IF(AND($AP2="x",$AW2="S",H3>=BC2),AY2-BC2,""))))


It does what it is supposed to do, except that if cell AY2 is blank (which it sometimes is), it returns #VALUE , which then messes up the BE column sum.


I would like it to calculate IF cell AY is NOT BLANK. If it is blank, it would like the formula to not evaluate, and return something that unlike a #VALUE , or #N/A, will allow column BE to sum without errors.


Any help much appreciated - thank you all!
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Just wrap that whole thing in another IF function:

=IF(AY2="","",your formula)
 
Upvote 0
Just wrap that whole thing in another IF function:

=IF(AY2="","",your formula)


Thank you Rory!

I do see that this should fix it up. But I now seem to have another issue. I see now that that AP2 can either contain an "x", or again, be blank - in the case of the formula in this row, it happens to be blank.

In any event, when entering the formula (now modified with your addition) below:


=IF(AY2="","",IF(AND($AP2="x",$AW2="L",I3>BC2),J3-AY2,IF(AND($AP2="x",$AW2="S",H3<BC2),AY2-J3,IF(AND($AP2="x",$AW2="L",I3<=BC2),BC2-AY2,IF(AND($AP2="x",$AW2="S",H3>=BC2),AY2-BC2,""))))


...excel warns me that I have an error and it points to the "x" indicated below (large) as the source of the error.

=IF(AY2="","",IF(AND($AP2="x",$AW2="L",I3>BC2),J3-AY2,IF(AND($AP2="x",$AW2="S",H3<BC2),AY2-J3,IF(AND($AP2="x",$AW2="L",I3<=BC2),BC2-AY2,IF(AND($AP2="x",$AW2="S",H3>=BC2),AY2-BC2,""))))

Any thoughts? Thanks again so much for the guidance!
 
Upvote 0
Dear Rory -

Have just worked with this some more and it somehow seems correct now - after pasting in a second time, excel offered a modification, and I took it:

[FONT=&quot]=IF(AY2="","",IF(AND($AP2="x",$AW2="L",I3>BC2),J3-AY2,IF(AND($AP2="x",$AW2="S",H3<BC2),AY2-J3,IF(AND($AP2="x",$AW2="L",I3<=BC2),BC2-AY2,IF(AND($AP2="x",$AW2="S",H3>=BC2),AY2-BC2,"")))))

I cannot as of yet discern what is different, but it seems to be good now - thanks to you.

Much appreciated and thank you again -[/FONT]
 
Upvote 0
Glad to help.

FWIW, I think that can be shortened to this:

=IF(AY2="","",IF($AP2="x",IF($AW2="L",IF(I3>BC2,J3-AY2,BC2-AY2),IF($AW2="S",IF(H3< BC2,AY2-J3,AY2-BC2),"")),""))
 
Last edited:
Upvote 0
Rory -
So sorry, got the flu! Just now coming up of air...ugh.

I wanted to say thank you again for the help on this, it is very helpful - thanks for your time.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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