+ Reply to Thread
Results 1 to 9 of 9

Excel 2007 : SUMIF help:code MA

  1. #1
    Registered User
    Join Date
    01-24-2011
    Location
    Cleveland, OH
    MS-Off Ver
    Excel 2007
    Posts
    4

    SUMIF help:code MA

    I'm trying to do a formula and it's not working. I have 31 columns, each representing 1 day of the calendar month. I want to be able to use number or preferably letter codes to represent numericals.
    So, for example, cell A1 I input the number 6 or the code MA and in the total column (after day 31) I want it to total that if 6 is in cell A1, then it equals 1. and then add each day - for example if each day's code is a 6, then the total should be 31. I also want to be able to make it so other codes can represent ZERO instead of ONE.
    I began my formula like this but it's not working (in this ex, day 1 begins in column 13:
    =(SUMIF(F5:AJ5,6)/6)+(SUMIF(F5:AJ5,1)/1)+(SUMIF(F5:AJ5,9)/9)+(SUMIF(F5:AJ5,8)/8)+(SUMIF(F5:AJ5,2)/2)+(SUMIF(F5:AJ5,4)/4)+(SUMIF(F5:AJ5,7)/7)+(SUMIF(F5:AJ5,10)/10)+(SUMIF(F5:AJ5,5)/5)+(SUMIF(F5:AJ5,11)/11)+(SUMIF(F5:AJ5,15)/15)+(SUMIF(F5:AJ5,18)/18)+(SUMIF(F5:AJ5,3)/3)

    I tried COUNTIF and in the totals column it added all my entries. Not what I'm looking for.

    Say if A1 thru AE1 were all 6's, the total in column AF1 should be 31.

    I know it's SUMIF because it worked on my Excel 2000 sheet. Converting to 2007 is the problem. I tried to open my old sheet and the calculations aren't working, as if it's not recognizing!

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

    re: SUMIF help:code MA

    If you want every entry to equal 1 then you can just use COUNTA, e.g.

    =COUNTA(F5:AJ5)

    if some codes shouldn't be counted then you can subtract those, e.g. if 7 and "x" should represent zero then use

    =COUNTA(F5:AJ5)-SUM(COUNTIF(F5:AJ5,{"x","7"}))
    Audere est facere

  3. #3
    Registered User
    Join Date
    01-24-2011
    Location
    Cleveland, OH
    MS-Off Ver
    Excel 2007
    Posts
    4

    re: SUMIF help:code MA

    What i want is precisley this:
    if the cell says 6, I want it to count 1. If the cell says 30, i want it to count zero.
    In detail, numbers 1, 2, 3, 4, 5, 6 all equal a 1.
    30 and 20 equal zero.
    Those are the # codes I use for this spreadsheet (which is a roster of residents in a nursing facility - it's to keep track of census for each day).
    COUNTA will just do math for me... not quite what I need - does any of this make sense? Perhaps I can upload an example?

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    re: SUMIF help:code MA

    Your formula as is would give a result of 31 in all cases unless there are 0s in any cells or anything higher than 20 or text..

    This would do similar:

    =SUMPRODUCT(--(COUNTIF(F5:AJ5,ROW(INDIRECT("1:20")))))

    Not sure if that is the question or resolution or not??
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

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

    re: SUMIF help:code MA

    In your original formula you are effectively counting each instance of each number as 1....so COUNTA will do that for you too ........only more succinctly. (and you said you wanted to use letter codes so COUNTA counts those too)...then you only need to subtract the codes that are equal to zero....so adapting my suggestion from the last post, if your only "Zero codes" are 20 and 30 try

    =COUNTA(F5:AJ5)-SUM(COUNTIF(F5:AJ5,{"20","30"}))

  6. #6
    Registered User
    Join Date
    01-24-2011
    Location
    Cleveland, OH
    MS-Off Ver
    Excel 2007
    Posts
    4

    re: SUMIF help:code MA

    I see how all of your suggestions can work but none of them are working - I don't think it's me or you. Is it possible that I've done something where Excel simply won't take a formula? I'm clicking on the cell where I want to calculate to, and have tried typing in, copying in, etc - all sorts of formulas that I've made in MS Word (so I can edit) and nothing's happening. The formula is THERE but it's not changing when I change the variables in the corresponding cells!

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    re: SUMIF help:code MA

    So you actually see the formula and not the results?

    If so, perhaps the underlying cell is formatted as text?

    Select it and format the cell to General, then hit F2 and Enter..

    If the calculations aren't happening, do you have Automatic calcs turned on?

    Go to Formulas tab and then select Automatic Calculations from Calculation Options.

  8. #8
    Registered User
    Join Date
    01-24-2011
    Location
    Cleveland, OH
    MS-Off Ver
    Excel 2007
    Posts
    4

    re: SUMIF help:code MA

    Quote Originally Posted by NBVC View Post
    So you actually see the formula and not the results?

    If so, perhaps the underlying cell is formatted as text?

    Select it and format the cell to General, then hit F2 and Enter..

    If the calculations aren't happening, do you have Automatic calcs turned on?

    Go to Formulas tab and then select Automatic Calculations from Calculation Options.
    no, it just stays the same - for instance I've entered a code in every day until yesterday, so that's 1st thru 23rd. Well on my total column, it stays at 23, even tho i've entered a 20 in on some "days", which would be zero, so it wouldn't be 23 days, it'd be be the total less the days I input 20. Does that make sense? It's like it's not "working" yet it's sitting there with no "error" notification or anything.

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

    re: SUMIF help:code MA

    Which formula are you using?

+ 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