+ Reply to Thread
Results 1 to 11 of 11

Need help with IF statement and adding up values from an Excel spreadsheet

  1. #1
    Registered User
    Join Date
    01-21-2012
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    19

    Need help with IF statement and adding up values from an Excel spreadsheet

    Hi everyone,
    I need help with a formula that I couldn't figure out on my own, so I registered here today to ask for your help!

    I have a spreadsheet where in one of the columns there's a heading "Net Income:". The actual net income is right below, in the same column, but next row. For example, the text "Net Income:" is in F5, and the actual number is in F6.
    The spreadsheet is logically divided into ~50 objects, so there are 50 "Net Income" values.

    How do I do the following:
    Go through the "F" column, and if the text is "Net Income:", take the value right below (again, value is in the same column, row + 1) and display the total (all 50 added up) on top, or do other operations on them such as AVERAGE, etc.

    Note: If someone reading this thinks it's easier to hardcode (i.e. just manually sum up all the values I need), I've thought that too, but the problem is -- new objects are added every day, so I would have to constantly update manually... so this is not a good idea. My job is to automate this and not hardcode.
    Thanks!

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,464

    Re: Need help with IF statement and adding up values from an Excel spreadsheet

    It would look something like this.

    =SUMIF($F$5:$J$13,$F$5,$F$6:$J$15)

    But it might need adjustment to reflect the ranges you actually have.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    01-21-2012
    Location
    Lancashire
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Need help with IF statement and adding up values from an Excel spreadsheet

    Why do you have a header "Net income" above every object? Logically, you would have a single header for a column, e.g. Name in A1, Phone number in B1, Net income in C1, etc. You can then perform whatever you want on the cells below the headers, e.g. Sum(C2:C60), as they only contain the values.
    Regards, GMBIT

  4. #4
    Registered User
    Join Date
    01-21-2012
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Need help with IF statement and adding up values from an Excel spreadsheet

    Quote Originally Posted by TMShucks View Post
    It would look something like this.

    =SUMIF($F$5:$J$13,$F$5,$F$6:$J$15)

    But it might need adjustment to reflect the ranges you actually have.


    Regards, TMS
    Hi, thanks for your help, but this is something different...
    Maybe this is not possible in Excel?

    Basically, I need to go through a column, range is F4:F1000 and if the text is "Net Income:", take the value from the same column, ROW + 1 (right below it). There is about 50 "Net Income:" tags right now, but it keeps increasing, in a couple of months it will be 100 "records".
    It's an old company that hasn't gotten around to using a database for this, they use Excel for everything and this is the format I have to work with. Thank you.

  5. #5
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Need help with IF statement and adding up values from an Excel spreadsheet

    Hi Mike

    Maybe something like this,could works for you.

    =IF(AND(F4="Net Income";ISNUMBER(F5));F5;0)

    Hope to helps you
    Attached Files Attached Files
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,464

    Re: Need help with IF statement and adding up values from an Excel spreadsheet

    Did you try the formula that I provided, changing it to just column F?


    =SUMIF($F$5:$F$13,$F$5,$F$6:$F$15)


    HTML Code: 

    Regards, TMS

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,464

    Re: Need help with IF statement and adding up values from an Excel spreadsheet

    Or, you could make it dynamic, with or without named ranges:

    =SUMIF($F1:INDEX($F:$F,MATCH("Total",$G:$G,0)),"Net Income",($F2:INDEX($F:$F,MATCH("total",$G:$G,0))))


    To make this work, put the word "Total", no quotes, in column G beyond the last value to be summed and the formula elsewhere, perhaps under the word "Total"

    HTML Code: 

  8. #8
    Registered User
    Join Date
    01-21-2012
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Need help with IF statement and adding up values from an Excel spreadsheet

    Hi and thank you everyone for the help!
    The only way I was able to get this to work is by doing what Fotis suggested and making a hidden field with the word "total" in an unused column, so basically the formula that's hidden looks like this:
    =IF(AND(F13="Net Income",ISNUMBER(F14)),F14,0)
    Then, the formula in the summary just sums up everything in that column.
    So thank you very much for that solution!

    The problem with this is that I get 20-50 of these records per week, so I have to update the new records manually. The people that add those records will not create this hidden value.
    Perhaps Excel is not capable of the functionality I was looking for, which is LOOP THROUGH all rows in a single column, and if the words "Net Income" are found, get the value from the next row, same column.

    I have told the client that they need to implement a database, but for now, this is the way they're doing it.

  9. #9
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Need help with IF statement and adding up values from an Excel spreadsheet

    Ηι Μικε.
    The problem with this is that I get 20-50 of these records per week, so I have to update the new records manually...
    Why you have to do this?

    Glad to my suggestion helped.

    Unfortunately my English is not good, not allow me to figure out what the problem is and be able to suggest something different..

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,464

    Re: Need help with IF statement and adding up values from an Excel spreadsheet

    Have you tried:

    =SUMIF($F$1:$F$1000,"Net Income",$F$2:$F$1001)

    See attachment for examples
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    02-03-2012
    Location
    Hertfordshire, UK
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Need help with IF statement and adding up values from an Excel spreadsheet

    Hi MikeSeattle

    Does your column include other numerical values which you want ignored or does it just contain the labels 'Net Income' and the numerical values you want to include?

    If it only includes the labels and the desired values, just SUM the whole column. Excel ignores the text and just performs the mathematical operation on the numerical values.

    I'm afraid I have Excel 2010 and you have 2003 so this may not work on your version. All of the other arithmetic operations work too.

+ 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