My macro for sheets VP and VP2 that subtotals results of a query was working fine. The workbook has 2 sheet, VP and VP2 which are subtotaled.
I needed to add a copy function to sheet VP to copy the subtotal lines to the top of the sheet (beginning at row 5). This may or may not be working because I now get the subtotal method of range error and the macro doesn't run. I am not sure why this now doesn't work. Any help would be appreciated. The data is supplied to the file via a query from our financial system.
I needed to add a copy function to sheet VP to copy the subtotal lines to the top of the sheet (beginning at row 5). This may or may not be working because I now get the subtotal method of range error and the macro doesn't run. I am not sure why this now doesn't work. Any help would be appreciated. The data is supplied to the file via a query from our financial system.
Code:
Sub AddSum()
'
' AddSum Macro
'
Sheets("VP").Select
Selection.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(7, 8, 9, 10, 11)
'
Dim b As Range
For Each b In Range("VP")
If b.Value Like "*Public,John Q. Total*" Then
Cells(b.Row).EntireRow.Copy
Cells(b.Row, 5).PasteSpecial _
Operation:=xlPasteSpecialOperationNone
End If
Next b
'
'
Sheets("VP2").Select
Selection.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(7, 8, 9, 10, 11)
End Sub
Last edited: