+ Reply to Thread
Results 1 to 5 of 5

How to sum multiple columns automatically

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

    How to sum multiple columns automatically

    Where I work we perform a monthly inventory count and I must create a report for the production managers. In this report I have multiple columns to sum and after 5 years of doing this manually, it has gotten old. There has to be a way to search out these cells with code and perform this task automatically, but I'm not sure how to do it. While watching a video on VBA, I found the following code promising and can find the first empty cell when running it, but not sure what to do to insert the function and if I did, I'm not sure how to search out for the next cell to enter the function.

    Please Login or Register  to view this content.
    By recording a macro, I can see the code to add the sum, but still lost as what needs to be done.

    Please Login or Register  to view this content.
    I have attached a spreadsheet with sample data with highlighted cells that need a sum of the cells above it.

    I cannot upload a spreadsheet or image from my work computer so hopefully the explanation will be good enough. If not, I will upload it from home later tonight.

    BTW... if the cells that are required to be SUMMED were always the same, I could just use a recorded macro to do the job. However, because inventory items and added and deleted throughout any given month, these locations are not always the same.

    Brian
    Last edited by BBoydAnchor; 12-27-2011 at 10:20 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: How to sum multiple columns automatically

    Hello BBoydAnchor ,

    Welcome to the Forum!

    Here is a macro that will ask you for the first cell of the column you want the sum for. This will display the sum from the starting cell to the last cell with data in the column. Your needs may be different and the code may need to adjusted accordingly but at least it is a start.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  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 automatically

    I appreciate the effort, but it's not exactly what I need. I was hoping to upload the spreadsheet from home over the weekend, but was not able to. The code you provided puts the sum in a message box and I need the cell to be filled with the sum.

    Below is code that sort of does what I need it to. Cell "F4" will always be the same so the code can start there. It is the other cells like "F15", "F16" and so on that will change each month. I know that "Offset" is needed to be used to move down to the next empty cell to add the SUM formula, but not sure how it should be coded and I'm not sure if the SUM formula is correct.

    Please Login or Register  to view this content.

  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 automatically

    OK. I did a little more reading and figured it out. However, there is a lot more code than there probably should be and the SUM function is hard coded for only 10 cells. Also I would like to include a Grand Total that includes all the sums for each department.

    These columns show the inventory values before and after the count.

    Please Login or Register  to view this content.
    Last edited by BBoydAnchor; 12-20-2011 at 09:47 AM.

  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 automatically


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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