Results 1 to 5 of 5

Sub Grouped Autosum Function

Threaded View

  1. #1
    Registered User
    Join Date
    05-20-2015
    Location
    United States
    MS-Off Ver
    Microsoft Office 2013
    Posts
    36

    Question Sub Grouped Autosum Function

    Hello Everyone,

    I am currently working on a macro that inserts a space between each individual person based off of their ID in column A. What I am now attempting to do is have the macro run an "autosum" function, based off of the purchases and split payment amounts in column K and L, and print the result in column P. For some reason, it is returning only one sum, which does not even match the sum of all purchases under the specific person. Below I have posted the portion of the code in question, as well as some screenshot to help illustrate my issue. Any help would be greatly appreciated.

     Dim lastrow As Long
         Dim x As Long, i As Long
         lastrow = Cells(Rows.Count, 1).End(xlUp).Row
         Application.ScreenUpdating = False
     
         For x = lastrow To 2 Step -1
             If Cells(x, 1).Value <> Cells(x - 1, 1).Value Then
                 If Cells(x, 1).Value <> "" Then
                     If Cells(x - 1, 1).Value <> "" Then
                         Cells(x, 1).EntireRow.Insert Shift:=xlDown
                     End If
                 End If
             End If
    
         Next x
         
         
         For i = 11 To 12
         For class = lastrow To 2 Step -1
         For Each numrange In Columns(i).SpecialCells(xlConstants, xlNumbers).Areas
         If Cells(class, 7).Value <> Cells(class - 1, 7).Value Then
            If Cells(class, 7).Value <> "" Then
                If Cells(class - 1, 7).Value <> "" Then
                
          sumaddr = numrange.Address(False, False)
          numrange.Offset(numrange.Count, 0).Resize(1, 1).Formula = "=SUM(" & sumaddr & ")"
          Cells(numrange.Cells(1, 1).Row, "P") = Cells(numrange.Cells(1, 1).Row, "P") + numrange.Offset(numrange.Count, 0).Resize(1, 1).Value
          numrange.Offset(numrange.Count, 0).Resize(1, 1).Clear
          c = numrange.Count
         
                End If
            End If
         End If
            
         Next numrange
         Next class
         Next i
         
         Application.ScreenUpdating = True
    What the macro is currently doing:

    Excel 4.JPG

    What I would LIKE the macro to do:

    Excel 5.JPG
    Last edited by joshuarobbins; 11-25-2015 at 05:14 PM. Reason: Solved

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Autosum Grouped Cells
    By joshuarobbins in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-25-2015, 09:33 AM
  2. [SOLVED] How to do an autosum like function rather than numbers, words.
    By Zaint in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-18-2014, 05:56 AM
  3. autosum function within a formula?
    By henrim in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-22-2013, 12:52 PM
  4. Autosum function in a Macro
    By Cambop in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-25-2012, 08:45 AM
  5. Autosum function Incorrect result
    By tartanswan in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-01-2008, 08:38 AM
  6. Nested if-function - autosum
    By vvorland in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-18-2008, 09:06 AM
  7. [SOLVED] Autosum function
    By Frankie in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-24-2006, 10:55 AM

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