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

rob51852

Board Regular
Joined
Jun 27, 2016
Messages
185
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

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Snakehips

Well-known Member
Joined
May 17, 2009
Messages
5,384
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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.
 

jmacleary

Well-known Member
Joined
Oct 5, 2015
Messages
1,056
Office Version
  1. 365
  2. 2007
Platform
  1. Windows
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))))
 

rob51852

Board Regular
Joined
Jun 27, 2016
Messages
185
Office Version
  1. 2016
Platform
  1. Windows
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.
 

jmacleary

Well-known Member
Joined
Oct 5, 2015
Messages
1,056
Office Version
  1. 365
  2. 2007
Platform
  1. Windows

ADVERTISEMENT

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)
 

jmacleary

Well-known Member
Joined
Oct 5, 2015
Messages
1,056
Office Version
  1. 365
  2. 2007
Platform
  1. Windows
You're welcome and thanks for the feedback.
 

Forum statistics

Threads
1,147,451
Messages
5,741,197
Members
423,648
Latest member
steel1968

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
Top