GaryNet0430
New Member
- Joined
- Apr 3, 2019
- Messages
- 1
I have a very large spreadsheet of data with dates (confirmed that they are proper dates to Excel as opposed to strings) that I am trying to group via VBA. When I run the code, I get an error.
With ptTable
' Set the row fields
.PivotFields("REALDATE").Orientation = xlRowField
'.PivotFields("OPNDTE (Month)").Orientation = xlRowField
.PivotFields("REASON").Orientation = xlRowField
' Add CDB_CATEGORY as filter - and set filter as 500
.PivotFields("CDB_CATEGORY").Orientation = xlPageField
.PivotFields("CDB_CATEGORY").CurrentPage = "Thermatech "
' Set the column fields
'.PivotFields("Title").Orientation = xlColumnField
' Set the data(value) fields
.PivotFields("DIVISION").Orientation = xlDataField
'.PivotFields("OPNDTE").Orientation = xlDataField
' Group the date by year and month
.PivotFields("REALDATE").LabelRange.Group _
Start:=True, End:=True, _
Periods:= _
Array(False, False, False, False, True, False, True)
End With
Done:
Exit Sub
EH:
MsgBox Err.Description & " BuildPivot.CreatePivot"
End Sub
The error is "Group method of Range class failed." Every example I've looked at shows that this should work. But, there is probably something really simple that I am missing.
With ptTable
' Set the row fields
.PivotFields("REALDATE").Orientation = xlRowField
'.PivotFields("OPNDTE (Month)").Orientation = xlRowField
.PivotFields("REASON").Orientation = xlRowField
' Add CDB_CATEGORY as filter - and set filter as 500
.PivotFields("CDB_CATEGORY").Orientation = xlPageField
.PivotFields("CDB_CATEGORY").CurrentPage = "Thermatech "
' Set the column fields
'.PivotFields("Title").Orientation = xlColumnField
' Set the data(value) fields
.PivotFields("DIVISION").Orientation = xlDataField
'.PivotFields("OPNDTE").Orientation = xlDataField
' Group the date by year and month
.PivotFields("REALDATE").LabelRange.Group _
Start:=True, End:=True, _
Periods:= _
Array(False, False, False, False, True, False, True)
End With
Done:
Exit Sub
EH:
MsgBox Err.Description & " BuildPivot.CreatePivot"
End Sub
The error is "Group method of Range class failed." Every example I've looked at shows that this should work. But, there is probably something really simple that I am missing.