Hello All,
First time posting so bear with.
I have a spreadsheet (Global Template) with a pivot table referencing data from another file (not open and a year to date file information).
I want my macro to show the detail of the grand total on a new sheet, I have the code in place for this.
The only problem is that when you first run the macro I get the error message (subsequent run of the macros there is no error message.
Run-time error '424':
Object Required
This only happens when i have another action after the show detail. I if i do not have another action then it works fine.
I am confused as i need further actions.
My coding (which i found on research yesterday, can't remember but very grateful to the individual) is
This works fine until i add this line of code before the End Sub
For reference sheet7 is the name of the sheet created following the show detail whilst sheet2 is the pivot table.
Any help would be most approeciated as i am getting very frustrated and have the lack of understanding.
Cheers
First time posting so bear with.
I have a spreadsheet (Global Template) with a pivot table referencing data from another file (not open and a year to date file information).
I want my macro to show the detail of the grand total on a new sheet, I have the code in place for this.
The only problem is that when you first run the macro I get the error message (subsequent run of the macros there is no error message.
Run-time error '424':
Object Required
This only happens when i have another action after the show detail. I if i do not have another action then it works fine.
I am confused as i need further actions.
My coding (which i found on research yesterday, can't remember but very grateful to the individual) is
Code:
Sub ShowGrandTotalDetail()'--shows grand total drill down detail of first pivotTable
' in activesheet.
Dim sMessage As String
With ActiveSheet.PivotTables(1)
'--validate requirements met to allow grand totals drilled down
Select Case True
Case .DataFields.Count = 0
sMessage = "Must have at least one DataField."
Case .RowFields.Count + .ColumnFields.Count = 0
sMessage = "Must have at least one RowField or ColumnField."
Case .RowFields.Count And Not .RowGrand
sMessage = "Grand Totals are Off for Rows."
Case .ColumnFields.Count And Not .ColumnGrand
sMessage = "Grand Totals are Off for Columns."
Case Else
'--ok- requirements met
End Select
If Len(sMessage) = 0 Then
With .TableRange1
'--drill down on last cell in pivot
.Cells(.Rows.Count, .Columns.Count).ShowDetail = True
End With
Else
MsgBox Prompt:=sMessage, Title:="Grand Totals detail can't be shown", _
Buttons:=vbExclamation
End If
End With
End Sub
This works fine until i add this line of code before the End Sub
Code:
Sheet7.Name = "GL DATA"
For reference sheet7 is the name of the sheet created following the show detail whilst sheet2 is the pivot table.
Any help would be most approeciated as i am getting very frustrated and have the lack of understanding.
Cheers