Results 1 to 5 of 5

How to sum multiple columns automatically

Threaded View

  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.

    Sub FindFirstEmptyCell_DoLoop()
    
        Worksheets("Compare").Activate
        Range("F5").Activate
        
        Do
        
            If ActiveCell.Value = "" Then Exit Do
            ActiveCell.Offset(1, 0).Activate
            
        Loop
    
    End Sub
    By recording a macro, I can see the code to add the sum, but still lost as what needs to be done.

        Range("F15").Select
        ActiveCell.FormulaR1C1 = "=SUM(R[-10]C:R[-1]C)"
        Range("F27").Select
        ActiveCell.FormulaR1C1 = "=SUM(R[-10]C:R[-1]C)"
        Range("I71").Select
    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.

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