+ Reply to Thread
Results 1 to 10 of 10

Sum function that skips rows when dragged down

Hybrid View

  1. #1
    Registered User
    Join Date
    08-26-2014
    Location
    Oklahoma City, OK
    MS-Off Ver
    2010
    Posts
    4

    Sum function that skips rows when dragged down

    Hello all,

    I have a program outputting data to an Excel file into a single column of 4 rows per measurement. I'd like to sum some of these and put the results in a summary table on the same sheet, but I only need the top two rows or the bottom two rows at a time for each measurement. For example:

    _B8: 1a ...... _E8: =_B8+_B9 (1a+1b)
    _B9: 1b ...... _E9: =B12+B13 (2a+2b)
    B10: 1c ...... E10: =B16+B17 (3a+3b)
    B11: 1d
    B12: 2a
    B13: 2b
    B14: 2c
    B15: 2d
    B13: 3a
    B14: 3b
    B15: 3c
    B16: 3d

    This should go on for hundreds, maybe thousands of rows, so I'd like to get it to where I can just Ctrl-Enter the data table. How can this be done? I've been playing around with the OFFSET function, but I haven't quite figured it out.

    Thanks.
    Last edited by lmmorrison; 08-26-2014 at 01:21 PM.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Sum function that skips rows when dragged down

    Are the real data numbers? If so, does this work for you?

    Formula: copy to clipboard
    =SUM(INDIRECT("b"&4+4*(ROW()-7)&":b"&5+4*(ROW()-7)))


    in E8 and copy down
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Valued Forum Contributor
    Join Date
    04-22-2014
    Location
    Auckland, New Zealand
    MS-Off Ver
    Office 365 (work) and Excel 2013 (home)
    Posts
    1,167

    Re: Sum function that skips rows when dragged down

    Assuming your data always starts in B8 try this
    Formula: copy to clipboard
    =SUM(OFFSET($B$8:$B$9,(ROWS($1:1)-1)*4,))
    Please add reputation by clicking on the * if I have helped.
    Please mark the thread SOLVED if your issue has been resolved.
    Thanks, Glenn.

  4. #4
    Registered User
    Join Date
    08-26-2014
    Location
    Oklahoma City, OK
    MS-Off Ver
    2010
    Posts
    4

    Re: Sum function that skips rows when dragged down

    Quote Originally Posted by gak67 View Post
    Assuming your data always starts in B8 try this
    Formula: copy to clipboard
    =SUM(OFFSET($B$8:$B$9,(ROWS($1:1)-1)*4,))
    Thanks for the quick replies! Both functions work great when starting at E8, but gak67's works in any other cell. gak, would you mind explaining a little bit more about the logic behind the formula so I can manipulate it for the rest of the data sheet?

    Thanks again guys.

  5. #5
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Sum function that skips rows when dragged down

    Quote Originally Posted by lmmorrison View Post
    Thanks for the quick replies! Both functions work great when starting at E8, but gak67's works in any other cell
    Because gak67 made the sensible choice! See here for a discussion on the merits of using ROWS as opposed to ROW in this type of construction:

    http://excelxor.com/2014/08/23/row-v...er-generation/

    Regards
    Click * below if this answer helped

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

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Sum function that skips rows when dragged down

    Quote Originally Posted by XOR LX View Post
    Because gak67 made the sensible choice!
    Cruel but fair... Go with GAK - he's already had some rep from me...

  7. #7
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Sum function that skips rows when dragged down

    Quote Originally Posted by Glenn Kennedy View Post
    Cruel but fair... Go with GAK - he's already had some rep from me...
    Sorry, Glenn!

    This ROW vs ROWS thing has become a bit of a thing for me! Nothing personal intended!

  8. #8
    Valued Forum Contributor
    Join Date
    04-22-2014
    Location
    Auckland, New Zealand
    MS-Off Ver
    Office 365 (work) and Excel 2013 (home)
    Posts
    1,167

    Re: Sum function that skips rows when dragged down

    Explanation:
    The SUM function is fairly easy, but it needs a range to sum. That's where the OFFSET function comes in.

    With the OFFSET function, if the range to offset from is greater than 1 cell the function keeps that range size, so that's why I had $B$8:$B$9 as the reference. If that's not the first two cells you want to sum then change it as appropriate.

    I then needed to tell Excel how many rows to offset. The ROWS function returns the number of rows in an array. The array I chose was one row high, but the first row was an absolute reference so as the formula is dragged or copied down the number of rows increases. I used $1:1 but could have used any single row array, such as $152:152, or even AB$20:BZ20, as long as it started as one row high and the first row reference was an absolute reference. The -1 is because you cannot have a range of 0 rows and to start with you need to offset 0 rows. If you had the starting reference as $B$4:$B$5 you wouldn't need the -1.

    Because your data is in blocks of 4 rows I multiplied the number of rows by 4.

    Hope that helps.

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Sum function that skips rows when dragged down

    No problem. I'm here to learn...

  10. #10
    Registered User
    Join Date
    08-26-2014
    Location
    Oklahoma City, OK
    MS-Off Ver
    2010
    Posts
    4

    Re: Sum function that skips rows when dragged down

    Thanks again everyone! Marking this one as solved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Offset function across columns when dragged down rather than rows.
    By Xiophoid in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-03-2013, 05:33 PM
  2. IF function randomly skips rows - why?
    By Heirak in forum Excel General
    Replies: 3
    Last Post: 03-05-2012, 08:09 AM
  3. Rows Not Visible: Enumeration Skips
    By jefftanner in forum Excel General
    Replies: 2
    Last Post: 10-08-2008, 05:31 PM
  4. How to copy formulas when it skips rows?
    By ladyjammie in forum Excel General
    Replies: 3
    Last Post: 01-29-2008, 07:06 PM
  5. Counting number of rows (with skips)
    By MasterMonk in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-04-2007, 04:11 PM

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