Help with IF statement

bellashahar

New Member
Joined
Nov 5, 2009
Messages
34
I need help with a formula.

Basically it's just H10-L10 (both are dates), however some in H and some in L show #VALUE! (this really can't be helped until data is populated).

So in my formula I would prefer if H or L has #VALUE! to return a blank cell instead of another #VALUE!

Any suggestions?

Thanks in advance.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Kaps_mr2

Well-known Member
Joined
Jul 5, 2008
Messages
1,544
If you are using Excel 2007 or later

IFERROR(H10-L10,"",H10-L10)

if you are using an earlier value of excel:-

IF(ISERR(H10-L10),"",H10-L10)

This will also work on Excel 2007.Thanks

Kaps
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try

=IF(OR(ISERROR(H10),ISERROR(L10)),"",H10-L10)
 

bellashahar

New Member
Joined
Nov 5, 2009
Messages
34

ADVERTISEMENT

You guys are awesome, thanks so much for the help!! :)
 

bellashahar

New Member
Joined
Nov 5, 2009
Messages
34
So I used VoG's formula

=IF(OR(ISERROR(H10),ISERROR(L10)),"",H10-L10)

Now is there a way to add something to color the cell if the dates fall in the same month? Like if H10 and L10 are both June then color the cell green. Or if the dates fall within two weeks of current date to color the cell yellow? :confused:

Again, thanks so much in advance for the help.
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
54,423
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

If you are using Excel 2007 or later

IFERROR(H10-L10,"",H10-L10)
Wouldn't it just be this? (Edit: per rwheeler formula in post #2)

IFERROR(H10-L10,"")
 
Last edited:

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
54,423
Office Version
  1. 365
Platform
  1. Windows
... however some in H and some in L show #VALUE! (this really can't be helped until data is populated).
It could be helped, by changing the formula that is producing the #VALUE error. The suggestions below are doing just that for your next formula, so presumably it could also be done for cells in column H and L. If you want to investigate that possibility, start by giving a current formula from column H and column L.
 

rwheeler

Board Regular
Joined
Apr 22, 2010
Messages
105
You can use conditional formatting to color the cells based on certain conditions. Depending on which version of Excel you are using, find the conditional formatting button and select "New Rule". Choose the option that allows you to use a formula to determine which cells to format. In the rule description, paste "=MONTH(H10)=MONTH(L10)" for the "Same Month" rule and the click "Format" to specify what color to maek the cell if the condition is true.

For the "Less than 2 weeks" Rule, use "=(H10-L10)<14"

Hope this helps
 

bellashahar

New Member
Joined
Nov 5, 2009
Messages
34
You can use conditional formatting to color the cells based on certain conditions. Depending on which version of Excel you are using, find the conditional formatting button and select "New Rule". Choose the option that allows you to use a formula to determine which cells to format. In the rule description, paste "=MONTH(H10)=MONTH(L10)" for the "Same Month" rule and the click "Format" to specify what color to maek the cell if the condition is true.

For the "Less than 2 weeks" Rule, use "=(H10-L10)<14"

Hope this helps

I'm not sure this is working right. I need it for all of H and L, not just row 10. Is that possible? or do manually have to create a new rule for each cell?
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,522
Messages
5,837,838
Members
430,517
Latest member
chessypack86

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