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.
 

Some videos you may like

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Kaps_mr2

Well-known Member
Joined
Jul 5, 2008
Messages
1,534
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
45,933
Office Version
365
Platform
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
45,933
Office Version
365
Platform
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?
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,916
Messages
5,514,136
Members
408,985
Latest member
bchaabi

This Week's Hot Topics

  • Sort code advice please
    Hi, I have the code below which im trying to edit but getting a little stuck. This was the original code which worked fine,columns A-F would sort...
  • SUMPRODUCT with nested If statement
    Hi everyone, Hope you're all well. I'm hoping someone will be able to point me in the right direction with a problem I'm having with a SUMPRODUCT...
  • VBA - simple sort is killing me!
    Hello all! This should be so easy, but not for me, apparently! I have a table of data that can be of varying lengths and widths. My current macro...
  • Compare Two Lists
    I have two Lists and I need to be able to Identify differences between them. List 100 comes from a workbook - the other is downloaded form the...
  • Formula that deducts points for each code I input.
    I am trying to create a formula that will have each student in my class start at 100 points and then for each code that I enter (PP for Poor...
  • Conditional formatting formula required for day of week and a value
    Hi, I have a really simple spreadsheet where column A is the date, column B is the activity total shown as a number and column C states the day of...
Top