+ Reply to Thread
Results 1 to 10 of 10

How to sum multiple columns that change sizes?

  1. #1
    Registered User
    Join Date
    12-15-2011
    Location
    Charleston, SC
    MS-Off Ver
    Excel 2010
    Posts
    43

    How to sum multiple columns that change sizes?

    Below is a macro that works to sum areas of a column when each column area is just 10 cells. However, the column areas are not always the same length each time needing to run the macro. Also this seems like a lot of code for this task.

    So how would this be coded to work when section areas would continually change? Also how would you create a Grand Total from all the subTotals?

    Please Login or Register  to view this content.
    Last edited by BBoydAnchor; 12-28-2011 at 11:34 AM.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: How to sum multiple columns that change sizes?

    How to help without a sample workbook ?



  3. #3
    Registered User
    Join Date
    12-15-2011
    Location
    Charleston, SC
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: How to sum multiple columns that change sizes?

    Quote Originally Posted by snb View Post
    How to help without a sample workbook ?
    Thanks for the quick response. The problem is that I'm behind a firewall at work and cannot upload any files. I will take the file home with me and upload it after work.

  4. #4
    Registered User
    Join Date
    12-15-2011
    Location
    Charleston, SC
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: How to sum multiple columns that change sizes?

    The sample spreadsheet is attached. Hopefully this will help.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    12-15-2011
    Location
    Charleston, SC
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: How to sum multiple columns that change sizes?

    I'm still struggling to find a solution to this problem. Not only have I searched here on this forum, but elsewhere on the web. The best I can do is in the code below. However, there is an issue with summing up the second set of numbers as the code loops back up to cell F5 and the issue is compounded as it moves onto the other sets of numbers.

    I'm sure there are some smart people out there that can solve this easily and without using old counter logic.

    Also it would be useful to have a cell at the bottom that provides a Grand Total of all the sums of the columns this code is adding up.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: How to sum multiple columns that change sizes?

    try it
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    12-15-2011
    Location
    Charleston, SC
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: How to sum multiple columns that change sizes?

    Thank you very much nilem. This code worked perfectly. I just wish that I understood it. Over time I will learn.

  8. #8
    Registered User
    Join Date
    12-15-2011
    Location
    Charleston, SC
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: How to sum multiple columns that change sizes?

    I ran the code in the example spreadsheet I uploaded and it worked great. However, when I ran the macro in the actual report, it did not work. Since I do not understand the code shared, I cannot say where the issue is and can only guess it is because each of the departments in reality contains more than 10 inventory items each. The format in the example is identical to the actual sheet except that there are many more rows than in the example I uploaded.

    So my question now is how can this code be modified to take into account that the row count will often change from month to month as items are either added to inventory or removed?

    Please Login or Register  to view this content.
    The formula above appears to have relative reference to the cells and will only sum a column consisting of just 10 cells.

  9. #9
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: How to sum multiple columns that change sizes?

    two versions
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    12-15-2011
    Location
    Charleston, SC
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: How to sum multiple columns that change sizes?

    Thanks Nilem, you are amazing!!! I will use the second option and hopefully I will one day understand it all.

    I have attached a sample spreadsheet along with my Macro Workbook with steps I take in this complete process. A lot of the code was recorded macros to begin with and the others were a combination of code people here on this forum helped with and from watching videos on Lynda.com.

    If anyone wants to look through this mess and provide any tips; that would be great, but can survive with what I have so far.

    Thanks again!
    Attached Files Attached Files

+ 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