Hey guys,
Need to be honest, total noob when it comes to VB but really keen to learn. (about to study this at uni :D)
I have an issue that I don't know how to resolve.
In excel 2010 I have a pivot table with a chart attached to it that I want to be able to refresh and stay at the same state but when I refresh the table it will undo my group settings.
So I thought I would make basic macro to do so. All goes well until I need to modify the pivot table then it error's out.
This is the code.
Range("A6").Select
ActiveSheet.PivotTables("PivotTable3").PivotCache.Refresh
Selection.Group Start:=41275, End:=41639, Periods:=Array(False, False, _
False, False, True, False, False)
With ActiveSheet.PivotTables("PivotTable3").PivotFields("Date")
.PivotItems("<1/01/2013").Visible = False * This is what is highlighted
.PivotItems(">31/12/2013").Visible = False
Can you guys help me with this?
Images below.
What I want
Attachment 98199
When I refresh
Attachment 98201
The Error
Attachment 98197
Need to be honest, total noob when it comes to VB but really keen to learn. (about to study this at uni :D)
I have an issue that I don't know how to resolve.
In excel 2010 I have a pivot table with a chart attached to it that I want to be able to refresh and stay at the same state but when I refresh the table it will undo my group settings.
So I thought I would make basic macro to do so. All goes well until I need to modify the pivot table then it error's out.
This is the code.
Quote:
Range("A6").Select
ActiveSheet.PivotTables("PivotTable3").PivotCache.Refresh
Selection.Group Start:=41275, End:=41639, Periods:=Array(False, False, _
False, False, True, False, False)
With ActiveSheet.PivotTables("PivotTable3").PivotFields("Date")
.PivotItems("<1/01/2013").Visible = False * This is what is highlighted
.PivotItems(">31/12/2013").Visible = False
Images below.
What I want
Attachment 98199
When I refresh
Attachment 98201
The Error
Attachment 98197