Hello there,
I have a simple subtotal macro where the last column, not included in the subtotal, needs to have the subtotals divided. This column has other results supplied by our financial system. As an example, column 11 is the result of column 10 / column 9. The subtotal macro subtotals columns 7, 8, 9 and 10 but not 11 - as it would be incorrect to subtotal 11. I need to take the subtotal in 9 and 10 and use them in the formula to get column 11. The subtotal occurs on 2 sheets within the workbook.
I have another workbook where I insert a blank line after the subtotal, I was wondering if this couldn't be used to do the formula but am not sure how to change is. Subtotal code and the line insert are below.
The last set of code is an attempt to try the formulas but not sure how to get them to work.
/code
Sheets("VP").Select
Selection.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(7, 8, 9, 10)
Sheets("VP2").Select
Selection.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(7, 8, 9, 10)
Dim c As Range
For Each c In Range("PROD")
If c.Value Like "*Total*" Then
c.Offset(1, 0).EntireRow.Insert
End If
Next c
'setting the cell references
A=.Cells("Totals", 9).Value
B=.Cells("Totals", 10).Value
.Cells("Totals",11)=B/A
[/code]
I have a simple subtotal macro where the last column, not included in the subtotal, needs to have the subtotals divided. This column has other results supplied by our financial system. As an example, column 11 is the result of column 10 / column 9. The subtotal macro subtotals columns 7, 8, 9 and 10 but not 11 - as it would be incorrect to subtotal 11. I need to take the subtotal in 9 and 10 and use them in the formula to get column 11. The subtotal occurs on 2 sheets within the workbook.
I have another workbook where I insert a blank line after the subtotal, I was wondering if this couldn't be used to do the formula but am not sure how to change is. Subtotal code and the line insert are below.
The last set of code is an attempt to try the formulas but not sure how to get them to work.
/code
Sheets("VP").Select
Selection.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(7, 8, 9, 10)
Sheets("VP2").Select
Selection.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(7, 8, 9, 10)
Dim c As Range
For Each c In Range("PROD")
If c.Value Like "*Total*" Then
c.Offset(1, 0).EntireRow.Insert
End If
Next c
'setting the cell references
A=.Cells("Totals", 9).Value
B=.Cells("Totals", 10).Value
.Cells("Totals",11)=B/A
[/code]
Last edited: