# Help with IF statement

#### bellashahar

##### New Member
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?

### 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).

#### rwheeler

##### Board Regular
Iferror(Formula,"")

#### Kaps_mr2

##### Well-known Member
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
Try

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

#### bellashahar

##### New Member

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

#### bellashahar

##### New Member
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?

Again, thanks so much in advance for the help.

#### Peter_SSs

##### MrExcel MVP, Moderator

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
... 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
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
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?

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.

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.

### Which adblocker are you using?

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

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