+ Reply to Thread
Results 1 to 10 of 10

Excel 2007 : Formula need few tweaks to handle blanks properly.

  1. #1
    Forum Contributor spiros63's Avatar
    Join Date
    04-23-2012
    Location
    Voula Attikis - Greece
    MS-Off Ver
    Excel 2016
    Posts
    136

    Formula need few tweaks to handle blanks properly.

    Hi guys,

    What we need is someone better than us in Excel to modify, adjust or do something else to a formula
    that fails to handle blanks properly.

    In the attached file you will find a small but clear example.

    Any help would be greatly appreciated !

    Attached Files Attached Files
    Last edited by spiros63; 07-09-2012 at 05:20 AM.
    Happiness = (Consumption/Desire)

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Formula need few tweaks to handle blanks properly.

    Try changing the formula in L4 to
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    and in M4 to
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Contributor spiros63's Avatar
    Join Date
    04-23-2012
    Location
    Voula Attikis - Greece
    MS-Off Ver
    Excel 2016
    Posts
    136

    Re: Formula need few tweaks to handle blanks properly.

    Hmmm...

    As you can see in the re-uploaded file (comparing to expected results) still something is missing
    Attached Files Attached Files

  4. #4
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Formula need few tweaks to handle blanks properly.

    Is the series in Column K (Tot) correct, or are "CORRECT EXPECTED RESULTS" indeed correct?

    Seems to me, if you change the formula in L4 to
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    and in M4 to
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Then make the series in K4 down 1,2,3,4, ..... You get the result you are expecting.

    If you leave the series as 1,1,1,2,3,4,... you get a different, but logical result.

    P.S.
    Dont wrap single cells in SUM(), it makes your formulae hard to read.
    e.g.
    IF(SUM(M$3)=0,"",SUM(M$3)) is the same as IF(M$3=0,"",M$3), unless M3 is text in which case it will always return 0 (zero)
    Attached Files Attached Files
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

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

    Re: Formula need few tweaks to handle blanks properly.

    in l4 =COUNTIF($J$4:J4,">=0") and in m4 =COUNTIF($J$4:J4,"<0")

    or not to fill in when blank
    =IF(J4="","",COUNTIF($J$4:J4,">=0"))
    =IF(J4="","",COUNTIF($J$4:J4,"<0"))
    Attached Files Attached Files
    Last edited by martindwilson; 07-09-2012 at 07:20 AM.
    "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

  6. #6
    Forum Contributor spiros63's Avatar
    Join Date
    04-23-2012
    Location
    Voula Attikis - Greece
    MS-Off Ver
    Excel 2016
    Posts
    136

    Re: Formula need few tweaks to handle blanks properly.

    Hey Marcol,

    Data in columns K, N, and O are correct.
    Basically they are an ascending numbering : K column of I column's (counts contracts), N column of J column's (counts positives) and O column of J column's (counts negatives).

    As you you'll see in the re-uploded file we need something more

    p.s. It was nice to see you again
    Attached Files Attached Files

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

    Re: Formula need few tweaks to handle blanks properly.

    you do not need the ifs use the countif as i showed you see what i posted its done
    as for the other column k one ,in k4 put 1 ,in k5 put
    =IF(COUNTIF($I$4:I5,I5)>1,K4,K4+1) drag down
    Attached Files Attached Files
    Last edited by martindwilson; 07-09-2012 at 07:58 AM.

  8. #8
    Forum Contributor spiros63's Avatar
    Join Date
    04-23-2012
    Location
    Voula Attikis - Greece
    MS-Off Ver
    Excel 2016
    Posts
    136

    Re: Formula need few tweaks to handle blanks properly.

    @Martin

    Speechless !
    So easy, so simple...
    Looking for my nose I went 1000 miles away...

    Thanks a lot Martin !!!

    (for bringing me back to earth)

  9. #9
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Formula need few tweaks to handle blanks properly.

    Well spotted Martin!
    I was letting the tail wag the dog assuming that Column "Tot" was a control column.

    @ spiros, further to post #4

    This is possibly an example of when you might use SUM() with a single cell.
    Instead of putting 1 in K4 as Martin suggests put this
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Drag/Fill Down
    All is well

    Now put some text in K3, say a header, the formula will fail

    Change the formula to
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Drag/Fill Down
    All is well again!
    You could also use
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    SUM() treats text as 0 (zero)

  10. #10
    Forum Contributor spiros63's Avatar
    Join Date
    04-23-2012
    Location
    Voula Attikis - Greece
    MS-Off Ver
    Excel 2016
    Posts
    136

    Re: Formula need few tweaks to handle blanks properly.

    Well spotted, by you this time Marcol !

    Indeed the previous formula would have fail if in K3 I'd put a header.

    There are no words guys to thank you enough.

    1.jpg

    Check the attachment !!

+ 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