Return Blank Cell When Another Cell is Blank in Nested IF Formula

rob51852

Board Regular
Joined
Jun 27, 2016
Messages
190
Office Version
  1. 2016
Platform
  1. Windows
Hi guys,

I have this formula and want to add a condition that if cell D5 is blank the formula should return a blank. At the moment it returns "FALSE" and I can't work out how to do it,

Code:
=IF(D5="L",ROUND(ABS(IF(D5="L",(F5-1)*E5)-IF(G5<>"",(H5-1)*G5)-IF(I5<>"",(J5-1)*I5)-IF(K5<>"",(L5-1)*K5)-IF(M5<>"",(N5-1)*M5)-IF(O5<>"",(P5-1)*O5)),2),IF(D5="B",ROUND(ABS(IF(D5="B",(F5-1)*E5)-IF(G5<>"",(H5-1)*G5)-IF(I5<>"",(J5-1)*I5)-IF(K5<>"",(L5-1)*K5)-IF(M5<>"",(N5-1)*M5)-IF(O5<>"",(P5-1)*O5)),2)))

Can anyone help?

Thanks
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Unless I'm missing something then...

VBA Code:
=IF(D5="","",IF(D5="L",ROUND(ABS(IF(D5="L",(F5-1)*E5)-IF(G5<>"",(H5-1)*G5)-IF(I5<>"",(J5-1)*I5)-IF(K5<>"",(L5-1)*K5)-IF(M5<>"",(N5-1)*M5)-IF(O5<>"",(P5-1)*O5)),2),IF(D5="B",ROUND(ABS(IF(D5="B",(F5-1)*E5)-IF(G5<>"",(H5-1)*G5)-IF(I5<>"",(J5-1)*I5)-IF(K5<>"",(L5-1)*K5)-IF(M5<>"",(N5-1)*M5)-IF(O5<>"",(P5-1)*O5)),2))))

Hope that helps.
 
Upvote 0
Hi there. I have wrapped an extra condition around your formula to return a blank, but I strongly suggest you rework it. At the moment, you have a whole lot of IF statements with no setting if the condition is false - this may lead to other problems.
VBA Code:
=IF(D5="","",IF(D5="L",ROUND(ABS(IF(D5="L",(F5-1)*E5)-IF(G5<>"",(H5-1)*G5)-IF(I5<>"",(J5-1)*I5)-IF(K5<>"",(L5-1)*K5)-IF(M5<>"",(N5-1)*M5)-IF(O5<>"",(P5-1)*O5)),2),IF(D5="B",ROUND(ABS(IF(D5="B",(F5-1)*E5)-IF(G5<>"",(H5-1)*G5)-IF(I5<>"",(J5-1)*I5)-IF(K5<>"",(L5-1)*K5)-IF(M5<>"",(N5-1)*M5)-IF(O5<>"",(P5-1)*O5)),2))))
 
Upvote 0
Thanks guys.

John, column D will only ever contain a blank cell, L or B. My intention was to copy the formula down another column and didn't want a column full of "FALSEs", Would you still suggest reworking it?

Thanks again.
 
Upvote 0
If it works for you, then no, but for instance this part of the formula
Rich (BB code):
 IF(G5<>"",(H5-1)*G5)
will return False if G5 is blank, the same with your tests for I5, K5, M5, etc. It is always good practice to put something for both outcomes of the test; in this case you would have something like:
Rich (BB code):
IF(G5<>"",(H5-1)*G5,0)
 
Upvote 0
You're welcome and thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,213,560
Messages
6,114,309
Members
448,564
Latest member
ED38

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