+ Reply to Thread
Results 1 to 8 of 8

Sum of Unknown Number of Rows

  1. #1
    Registered User
    Join Date
    09-25-2008
    Location
    Scotland
    Posts
    12

    Sum of Unknown Number of Rows

    I've tried this code but doesn't seem to work, any pointers?

    Please Login or Register  to view this content.
    Last edited by Colin_S; 08-16-2010 at 05:23 AM.

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Sum of Unknown Number of Rows

    It might be best if you tell us what you're trying to do.

    The code you've posted is trying to work on the active selection, but if you're going to select all of the rows you want to sum then you're only saving yourself 6 keystroke by not just typing in =SUM().

  3. #3
    Registered User
    Join Date
    09-25-2008
    Location
    Scotland
    Posts
    12

    Re: Sum of Unknown Number of Rows

    I have a huge macro that takes 6 spreadsheets and pulls it into 1, adds formulas to work out data, formats it all, pulls it into a pivot table and produces 8 summary report tabs and a master summary. The final piece I need is to add totals at the bottom of 7 columns in the 8 summary tabs. Each tab will have a different number of rows on a regular basis.

    What I am looking to do is get this small function working for 1 column, I will then basically paste it for each column required in each of the 8 summary tabs.
    Last edited by Colin_S; 08-12-2010 at 10:51 AM.

  4. #4
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Sum of Unknown Number of Rows

    OK, with you. Will there be the same number of rows in all 7 columns?

  5. #5
    Registered User
    Join Date
    09-25-2008
    Location
    Scotland
    Posts
    12

    Re: Sum of Unknown Number of Rows

    yes same in all 7 columns, I’ve got the code written to basically paste the formula into the other 6 columns once I get the first formula correct. And then replicate it over the other 8 tabs. The only issue I seem to be stuck at is how many rows to sum. If it was the same number of rows each time I’ve got it down, but as soon as the number of rows change it doesn’t work correct so I attempted my original code but I know it’s not correct.

    Thanks

  6. #6
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Sum of Unknown Number of Rows

    OK, try this.

    Please Login or Register  to view this content.
    It would be neater to pass the first row and the target column to the sub as parameters, but I'll leave it up to you to decide if you want to do that.

  7. #7
    Registered User
    Join Date
    09-25-2008
    Location
    Scotland
    Posts
    12

    Re: Sum of Unknown Number of Rows

    Perfect, just changed that first 6 to a 3 and it's bang on. Many thanks for you time and help.

  8. #8
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Sum of Unknown Number of Rows

    If you wanted to use R1C1 style:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

+ 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