+ Reply to Thread
Results 1 to 8 of 8

Leave empty if BLANK formula

  1. #1
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    Bogota, Colombia
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    1,377

    Leave empty if BLANK formula

    Dear Community,

    Good Afternoon from sunny but frosty kent, (already got through half a bag of coal today)!!

    Please see formulae below:

    I would like to add in this case below (if L2 is blank leave blank)

    =INT((L2-I2)/30)

    and in this case (if J3 is Blank leave blank)

    =12*(YEAR(J3)-YEAR(I3))+MONTH(J3)-MONTH(I3)

    I have been trying along the lines of =if"","",

    Do I need an IF OR or IF AND S'ment to solve this?

    Thanks All
    Darren
    Last edited by Blake 7; 10-21-2010 at 09:12 AM.
    Blake 7

    If your question has been answered, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

    If any member's response has helped to solve your problem, please consider using the scales icon on the top right of their post to show your appreciation.

    http://failblog.org/

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Leave empty if BLANK formula

    if(l2="","",INT((L2-I2)/30))
    if(j3="","",12*(YEAR(J3)-YEAR(I3))+MONTH(J3)-MONTH(I3))
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    Bogota, Colombia
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    1,377

    Re: Leave empty if BLANK formula

    Hey Martin, thanks for your time.
    Darren

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Leave empty if BLANK formula

    If you wanted to be **** about it given the explicit coercion taking place it would be best to test that the values are numeric (ie use COUNT)

    Please Login or Register  to view this content.
    valid "numeric strings" would technically be ok here (ie COUNT not strictly obligatory) but realistically we're not expecting anything other than numbers (true date values)

  5. #5
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    Bogota, Colombia
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    1,377

    Re: Leave empty if BLANK formula

    Hi Don,

    Nope, not into ****. Not for all the tea in China!

    Will check out your code. Then store it in my "Excel" Tips, Tricks and Help Folder!

    Darren

  6. #6
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    Bogota, Colombia
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    1,377

    Re: Leave empty if BLANK formula

    Hi Don, I tried this one Below and got -1340 so i changed the : between (L2:I2) to a , and it seems to work.


    [code]
    =IF(COUNT(L2:I2)<2,"",INT((L2-I2)/30))
    Any idea why?
    Cheers
    Darren

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Leave empty if BLANK formula

    Yes because what I posted was wrong.

    The colon tells XL the range is contiguous (ie L2 To I2) whereas the comma tells XL the ranges are non-contiguous (L2 and I2)
    In this instance you have a non-contiguous range (the 2nd example using colon is fine as the two cells of interest are contiguous)

  8. #8
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    Bogota, Colombia
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    1,377

    Re: Leave empty if BLANK formula

    Ahh i see. This one worked with the colon because it is in the next cell. ie contiguous.

    what you posted wasnt necessarily wrong as i didnt tell you in which cell i was going to put the Formula in!!

    Cheers and sorry to bother you with such minor excel functions! although its a slight relief from P and F type tools!!
    Cheers
    Don

    =IF(COUNT(I3:J3)<2,"",12*(YEAR(J3)-YEAR(I3))+MONTH(J3)-MONTH(I3))
    Last edited by Blake 7; 10-21-2010 at 10:29 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1