+ Reply to Thread
Results 1 to 13 of 13

how to make forumla that treat blank cells as a zero?

Hybrid View

  1. #1
    Registered User
    Join Date
    08-04-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    how to make forumla that treat blank cells as a zero?

    I'm quite new at this, so bear with my ignorance...

    I have this situation

    A B C D
    1 2 5 6
    2 3 6 7
    3 4 8
    4 5 7
    5 6 8 9
    6 7 9 10

    I want to create a formula that does this
    =(A1*5)+(B1*10)+(C1*10)+(D1*20) (just an example)
    But when I use Autofill it says value error with C3 and D4 because it is blank... I want to make the formula count the blank as zero making the last part in the add zero but still adding the rest up. I tried with the IFBLANK but I couldn't succeed

    Please help, and sorry if this is very low tech

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: how to make forumla that treat blank cells as a zero?

    =sumproduct(A1:D1, {5,10,10,20})
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    08-04-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: how to make forumla that treat blank cells as a zero?

    Sorry, I thought I could create a example that fitted situation. This is my real formula and the problem is that some of the cells are blank, and I want the same thing

    =(F3*G3)+(I10*J3)+(L3*M3)+(O3*P3)+(R3*S3)+(U3*V3)

    The thing is that I am using autofill, and in some of the colons the cells are blank (O3, S3, V3). Obviously if Excel treated this as zeros the last 3 paranthesis should be zero, but how to do this?

    Thank you for replying my n00bie question

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,047

    Re: how to make forumla that treat blank cells as a zero?

    shg in your 1st answer, what does the {5, 10,10,20} do?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Registered User
    Join Date
    08-04-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: how to make forumla that treat blank cells as a zero?

    The first question was only an attempt to examplify my problem. The long formula in the last question is the exact problem so can I preserve this formula
    =(F3*G3)+(I10*J3)+(L3*M3)+(O3*P3)+(R3*S3)+(U3*V3)
    and get to threat the last three parenthesises as zero IF one or more of the variables is a blank cell. Following cells could be blank: I3, J3, L3, M3, O3, P3, R3, S3, U3, V3

    disregard the first question as it was a faulty attempt to create a fictive example

    possible?

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,681

    Re: how to make forumla that treat blank cells as a zero?

    Presumably the "blanks" are not true blanks because Excel would treat those as zero, so I assume you have formulas in those cells that return a blank. Try this formula

    =N(F3)*N(G3)+N(I10)*N(J3)+N(L3)*N(M3)+N(O3)*N(P3)+N(R3)*N(S3)+N(U3)*N(V3)
    Audere est facere

  7. #7
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,681

    Re: how to make forumla that treat blank cells as a zero?

    Did you try my suggestion?

    Quote Originally Posted by daddylonglegs View Post
    =N(F3)*N(G3)+N(I10)*N(J3)+N(L3)*N(M3)+N(O3)*N(P3)+N(R3)*N(S3)+N(U3)*N(V3)

  8. #8
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,681

    Re: how to make forumla that treat blank cells as a zero?

    My previous suggestion should work for you - if L3, for example, contains a "formula blank" or any text then N(L3) will return a zero, otherwise it returns whatever number is in that cell

  9. #9
    Registered User
    Join Date
    08-04-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: how to make forumla that treat blank cells as a zero?

    I am very sorry for being so ignorant, but your somthing:something.... Doesn't that mean the range? Some of the colons are not to be included in my formula, and the {}, I don't know what to put in them in the last formula Gave you. This is my best shot


    =SUMPRODUCT((F3*G3)+(I10*J3)+(L3*M3)+(O3*P3)+(R3*S3)+(U3*V3), {and what goes here})

    It is to be used for autofill som all of the before-mentioned cells can be blank

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: how to make forumla that treat blank cells as a zero?

    My sumproduct formula will only work if the cells are contiguous.

    Ig the null strings in the cells are the result of formulas, why not change the formulas to returns zeros instead of null strings, e.g., instead of

    =if(some expression, some value, "")

    use

    =if(some expression, some value, 0)

    Then you can use your existing formula for the sum of products.

  11. #11
    Registered User
    Join Date
    08-04-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: how to make forumla that treat blank cells as a zero?

    because it is not the result of formulas...
    It is because some rows have blanks in the before-mentioned columns and some have numbers, and as I want one formula to cover all possibilities (e.g. some where O3, P3, ect. is blank and some where only V3, Y3, ect is blank)

    So I want to create the formula that does
    =(F3*G3)+(I10*J3)+(L3*M3)+(O3*P3)+(R3*S3)+(U3*V3)
    where any of the varibles (numbers) can be blank and will be counted as zeros
    examples:
    =(F3*G3)+(I10*J3=0)+(L3*M3=0)+(O3*P3=0)+(R3*S3=0)+(U3*V3=0)=(F3*G3)
    =(F3*G3)+(I10*J3)+(L3*M3)+(O3*P3)+(R3*S3=0)+(U3*V3=0) = =(F3*G3)+(I10*J3)+(L3*M3)+(O3*P3)
    =(F3*G3)+(I10*J3)+(L3*M3=0)+(O3*P3=0)+(R3*S3=0)+(U3*V3=0) =(F3*G3)+(I10*J3)

    This will happen in my stastistics at some point, and I need my formula to account for this

    Can't I write something "before"/"after" or "between" the original formula
    =(F3*G3)+(I10*J3)+(L3*M3)+(O3*P3)+(R3*S3)+(U3*V3)
    that threats the blanks as zeros?
    Isn't there a command that says, If any of the variables are zero "" then they should be understood as zero but that still calculates the rest?

    I am sorry that my skills is not better to explain what I mean but this would really make mhy day

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: how to make forumla that treat blank cells as a zero?

    You can never go wrong with a DLL formula

  13. #13
    Registered User
    Join Date
    06-08-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: how to make forumla that treat blank cells as a zero?

    Holy numerical conversion Batman! I have done so many workarounds, I didn't know there was a formula for it. Using the N() function is a game changer for me.

+ 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