+ Reply to Thread
Results 1 to 10 of 10

How to sum rows of varying ranges?

  1. #1
    Registered User
    Join Date
    03-11-2010
    Location
    Kansas City
    MS-Off Ver
    Excel 2003
    Posts
    8

    How to sum rows of varying ranges?

    My data is currently organized as follows:

    A1 100
    A2 100
    A3 blank
    A4 blank
    A5 100
    A6 100
    A7 100
    A8 blank
    A9 blank

    I'm lookin to accomplish the following:

    A1 100
    A2 100
    A3 (sum 200)
    A4 blank
    A5 100
    A6 100
    A7 100
    A8 (sum 300)
    A9 blank

    Essentially I want to sum the data set above the first blank row, the problem is the range of these data sets can be from 1 to 20 rows and I need to sum them regardless of their size. Is there a way to do this using a formula? The data has about 3000 rows so anything too complicated simply doesn't work.

    Thanks!
    Last edited by lbroxterman; 03-22-2010 at 02:30 PM.

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: How to sum rows of varying ranges?

    Maybe a macro on this lines?
    Please Login or Register  to view this content.

    Enter your typical data in column "A"

  3. #3
    Registered User
    Join Date
    03-11-2010
    Location
    Kansas City
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: How to sum rows of varying ranges?

    That works wonderfully! Thanks so much!

    How would i adjust the code if I wanted to start in A10 and end in A1000 and sort contents in column H?

    Thanks again for the help.

  4. #4
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: How to sum rows of varying ranges?

    Start and end no real problem, provided you know that A1000 is a blank row.
    But why do you want to end at A1000?
    The code ends at the last used cell in column "A"
    If you hard code the finish line what happens if say the last say 50 of the 1000 rows are blank?

    Sort on H is not too difficult, but what is the criteria?

    If you could post a dummy worksheet with sample data showing a before and after scenario it would make solving your problem much easier.

    It's dark o'clock here
    I'll look for your file tomorrow when the sun rises on Copeland Road

  5. #5
    Registered User
    Join Date
    03-11-2010
    Location
    Kansas City
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: How to sum rows of varying ranges?

    Hi Marcol,
    I have attached the exact format I use for this report. I need the spreadsheet to sum every highlighted yellow box. I want it to start in row 10 because I don't want the formatting in the first 9 rows to be changed. Likewise we also have disclaimers and logos at the bottom of the page in row 1000 that I don't want to be changed either. I use a simple "hide empty rows" macro to hide any empty rows after the last row. This allows this spreadsheet room to grow.

    I don't need to you design the whole spreadsheet, if you could simply show me how to sum a column other than column "A" I can probably figure out the rest.

    Again, Thanks so much for your assitance!
    Attached Files Attached Files

  6. #6
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: How to sum rows of varying ranges?

    Okay no problem,

    Can't do it right away. I'll get back to you asap.
    We have time zone problems again! I think you are about 6hrs "behind" me!

    Regards
    Alistair

  7. #7
    Registered User
    Join Date
    03-11-2010
    Location
    Kansas City
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: How to sum rows of varying ranges?

    Yeah I think Scottland is a couple time zones away from Kansas City By my account you should be drinking some pints about now

    Please take your time, no hurry and again thanks for the help!

  8. #8
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: How to sum rows of varying ranges?

    Hi Ibroxterman

    Try this out please.

    1/. Run the macro "SumWhen2blankRowsFound"

    2/. Check out the result.

    3/. Run the macro - nothing will happen This prevents overwriting and corrupting Data

    4/. Run the macro - "UnhideRows"

    5/. Add some groups of data in Column "A" only (Just for the Demo - You can fill in as much as you need later)

    6/. Add some figures in Columns "F" & "G" - Check out the result.

    7/. Run the macro "SumWhen2blankRowsFound" again

    I have not sorted on "H" as yet. I thought you might want to sort on "C" then on "H" rather than "H" alone.

    I'll add this next if that's what you want.

    Hope this helps

    Alistair

    P.S. The pub beacons.......

    Let me know how you get on.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    07-25-2012
    Location
    Americah
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: How to sum rows of varying ranges?

    Similar question what if I am trying to do a subtotal for something like this

    I1 100
    I2 100
    I3 blank
    I4 100
    I5 100
    I6 100
    I7 blank

    I'm lookin to accomplish the following:

    I1 100
    I2 100
    I3 (sum 200)
    I4 100
    I5 100
    I6 100
    I7 (sum 300)

    So its in the "I" column and only has 1 blank space, and the range is varying like the above post its just I only need the macro to work for 1 blank row not two and for the subtotal results to display inside the blank cell in the "I" column

  10. #10
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: How to sum rows of varying ranges?

    Hello lmproe27, and welcome to the forum.

    Unfortunately you have inadvertently broken one of the forum rules. Please read the following and make the necessary change. Thanks.

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.

+ 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