How to move accounting information from one tab to another while adding a "sum" with changing data

Hollywood9819

New Member
Joined
Dec 11, 2017
Messages
13
How do I populate data from one tab to another while adding a row with a "sum" between different sections (such as "program" in my visual aid). The problem is figuring out how to populate the new tab while information in the original data tab could have more (or less) "programs" added or subtracted each week. Because of this, doing a simple (=) from one tab to the other to populate data will not work as if I get more "programs" than what I originally set the new tab up to populate, I will be missing data, or it would be pushed to a different program. Attached is an example of the format I am trying to achieve. I need rows in the new tab to be able to adjust based off more or less data coming from the original tab.
 

Attachments

  • Capture.PNG
    Capture.PNG
    56.9 KB · Views: 9

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
How about this. The original information you supplied is on a sheet named "Original", starting with the header row in Cell A1 such as Cell A1.Value = "Assignment" (I deleted the row that said "Original Tab Information"). the newly completed Subtotal page will be added by the code and will be named "Summed".

subttl.xlsm
ABCDEFGHIJ
1AssignmentProgramNumberShort Text Budgeted Planned Commitments Obligation Actual Cost Assigned Costs
2CR1NEW1BUILDING$ 41,682.00 $ $ $ $
3CR1NEW1BUILDING$ - $ $ $ $
4CR1NEW1BUILDING$ -$ 20,002.18 $ $ $
5CR2WORN2LEVEL$ 33,000.00 $ $ 1,564.53$ 22,594.20$ 24,158.73
6CR2WORN2LEVEL$ - $ $ 21.19 $ $
7CR2WORN2LEVEL$ - $ $ 347.65 $ $
8CR3EXPIRED3LAND$ 7,118.21 $ $ $ 4,749.03$ 4,749.03
9CR3EXPIRED3LAND$ - $ $ $
10CR3EXPIRED3LAND$ -$ 7,118.21 $ $ 2,367.20$ 2,367.20
Original


VBA Code:
Sub subTtls()
    
    Dim wsO As Worksheet: Set wsO = Worksheets("Original")
    Dim rng As Range, col, subt As Single
    Dim TopofSection As Long, lastrow As Long, c As Long, i As Long
    
    Application.ScreenUpdating = False
    wsO.Copy After:=wsO
    ActiveSheet.Name = "Summed"
    Set rng = Range("A2:A" & Cells(Rows.Count, 1).End(xlUp).Row)
    With rng.Cells(rng.Rows.Count).Offset(1, 3)
        .Value = "TOTALS"
        .Interior.Color = RGB(180, 180, 180)
    End With
    For i = rng.Rows.Count To 1 Step -1
        With rng
            If i = 1 Then Exit For
            If .Cells(i) <> .Cells(i).Offset(-1) Then
                .Cells(i).EntireRow.Insert
                .Cells(i).Offset(, 3) = "TOTALS"
                .Cells(i).Offset(, 3).Interior.Color = RGB(180, 180, 180)
            End If
        End With
    Next
    col = Array("E", "F", "G", "H", "I", "J")
    lastrow = Cells(Rows.Count, "A").End(xlUp).Row
    For c = 0 To UBound(col)
        Do Until lastrow < 2
            TopofSection = Cells(lastrow, "B").End(xlUp).Row
            If Cells(lastrow - 1, 2) = "" Then TopofSection = lastrow
            subt = WorksheetFunction.Sum(Range(col(c) & TopofSection, col(c) & lastrow))
            Range(col(c) & lastrow).Offset(1, 0).Value = subt
            Range(col(c) & lastrow).Offset(1, 0).Interior.Color = RGB(180, 180, 180)
            lastrow = Cells(TopofSection, 2).End(xlUp).Row
        Loop
        lastrow = Cells(Rows.Count, "A").End(xlUp).Row
    Next
    Application.ScreenUpdating = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,045
Messages
6,122,830
Members
449,096
Latest member
Erald

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top