Function calOriginalAsset(sheetName As String, startCol As String, startRow As Integer)
Sheets(sheetName).Activate
Dim lngMyRow As Long
lngMyRow = Cells(Rows.Count, "B").End(xlUp).row
Range("B" & lngMyRow + 1).Formula = "=SUM(B7:B" & lngMyRow & ")" 'Sums from Row 7. Change to suit.
End Function
Sub getTotals()
Dim nm As Name
For Each nm In ThisWorkbook.Names
Dim n As String
n = Split(nm, "!")(0)
If Right(n, Len - 1) <> "Investment" Then
Range(nm).Offset(0, -1).Value = ""
Else
Range(nm).Offset(-2, -3).Clear
Range(nm).Offset(-2, -2).Clear
Range(nm).Offset(-2, -0).Clear
Range(nm).Offset(2, -3).Clear
Range(nm).Offset(2, -2).Clear
Range(nm).Offset(2, 0).Clear
Range(nm).Offset(0, -3).Clear
End If
Range(nm).Clear
nm.Delete
Next nm
calOriginalAsset "Original Assets", "B", 7, "Total_Assets", "TOTAL ASSETS"
calSum "Cap. Rec.", "D", 5, "Total_Receipts", "Total Receipts"
calSum "Cap. Disb.", "D", 5, "Total_Disbursements", "Total Disbursements"
calSum "Rev. Rec.", "D", 5, "Total_Revenue_Receipts", "Total Revenue Receipts"
calSum "Rev. Disb.", "D", 5, "Total_Revenue_Disbursements", "Total Revenue Disbursements"
calSum "Unrealized", "B", 3, "Unrealizedoriginalassets", "Total"
calSum "Invest on hand", "B", 3, "Invest_On_Hand", "Total"
calInvestment "Investment", "D", "F", 5
End Sub
Sheets(sheetName).Activate
Dim lngMyRow As Long
lngMyRow = Cells(Rows.Count, "B").End(xlUp).row
Range("B" & lngMyRow + 1).Formula = "=SUM(B7:B" & lngMyRow & ")" 'Sums from Row 7. Change to suit.
End Function
Sub getTotals()
Dim nm As Name
For Each nm In ThisWorkbook.Names
Dim n As String
n = Split(nm, "!")(0)
If Right(n, Len - 1) <> "Investment" Then
Range(nm).Offset(0, -1).Value = ""
Else
Range(nm).Offset(-2, -3).Clear
Range(nm).Offset(-2, -2).Clear
Range(nm).Offset(-2, -0).Clear
Range(nm).Offset(2, -3).Clear
Range(nm).Offset(2, -2).Clear
Range(nm).Offset(2, 0).Clear
Range(nm).Offset(0, -3).Clear
End If
Range(nm).Clear
nm.Delete
Next nm
calOriginalAsset "Original Assets", "B", 7, "Total_Assets", "TOTAL ASSETS"
calSum "Cap. Rec.", "D", 5, "Total_Receipts", "Total Receipts"
calSum "Cap. Disb.", "D", 5, "Total_Disbursements", "Total Disbursements"
calSum "Rev. Rec.", "D", 5, "Total_Revenue_Receipts", "Total Revenue Receipts"
calSum "Rev. Disb.", "D", 5, "Total_Revenue_Disbursements", "Total Revenue Disbursements"
calSum "Unrealized", "B", 3, "Unrealizedoriginalassets", "Total"
calSum "Invest on hand", "B", 3, "Invest_On_Hand", "Total"
calInvestment "Investment", "D", "F", 5
End Sub