+ Reply to Thread
Results 1 to 5 of 5

Sum X amount of cells in a row based on a seperate cell but ignoring blanks

  1. #1
    Registered User
    Join Date
    06-25-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2013 / 2016
    Posts
    69

    Sum X amount of cells in a row based on a seperate cell but ignoring blanks

    Hi,
    I'm new to this so I hope I explain correctly!!

    I have the formula SUM(C4:INDEX(C4:AK4,$AN$3)) where AN3 has the number of cells that are to be added, my problem is I need it to ingore blanks.

    Example: C4:AK4 = 18 cells & I need to add the first 5 cells that has values in them but if C7 was blank it would add cells C4,C5,C6,C8 & C9 (ignoring C8).

    Can anyone help please?

    Thanks

    How How
    Last edited by How How; 08-31-2012 at 09:26 AM.

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

    Re: Sum X amount of cells in a row based on a seperate cell but ignoring blanks

    This should sum the first 5 non-blanks in C4:AK4

    =SUM(C4:INDEX(C4:AK4,SMALL(IF(C4:AK4<>"",COLUMN(C4:AK4)-COLUMN(C4)+1),5)))

    confirmed with cTRL+SHIFT+ENTER
    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.

  3. #3
    Registered User
    Join Date
    06-25-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2013 / 2016
    Posts
    69

    Re: Sum X amount of cells in a row based on a seperate cell but ignoring blanks

    Thanks for that NBVC, that worked for some row's & not others, the ones that it worked for is the ones that had 5 or more values, but if the row has <5 values then it didn't work. On my sheet the entered values (By another formula) will vary from 1 to 18. have you a suggestion?

    Thanks for your help

    How How

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

    Re: Sum X amount of cells in a row based on a seperate cell but ignoring blanks

    Try:

    =SUM(C4:INDEX(C4:AK4,IFERROR(SMALL(IF(C4:AK4<>"",COLUMN(C4:AK4)-COLUMN(C4)+1),5),MATCH(10^10,C4:AK4))))

    confirmed with CTRL+SHIFT+ENTER

  5. #5
    Registered User
    Join Date
    06-25-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2013 / 2016
    Posts
    69

    Re: Sum X amount of cells in a row based on a seperate cell but ignoring blanks

    Perfect.......Thanks a lot NBVC, this forum is superb

+ 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