First post on this board and hoping for help:
Using excel 2010 and have an excel spreadsheet that has two sheets,
users add or modify a SharePoint form and one of the fields is "status", available options are New, final approval, manager approved, booked, claimed.
One of the columns in the data sheet is "status" and that is my first row Label in the pivot
I've created a very basic macro which when run switches to the data sheet and refreshes it, switches to the Overview sheet, refreshes the pivot and then sets the required checkbox's in the status filter, however if there is no status of the type I'm trying to set I get the following error
Run-time error '1004'
Unable to get the PivotItems property of the PivotField class
the VB is as follows:
Sheets("Data").Select
Range("F120").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
Sheets("Overview").Select
Range("A6").Select
ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
With ActiveSheet.PivotTables("PivotTable2").PivotFields("status")
.PivotItems("new").Visible = True
.PivotItems("booked").Visible = True
.PivotItems("final approval").Visible = True
.PivotItems("done").Visible = True
.PivotItems("claimed").Visible = True
End With
what I'm looking for therefore is a way for each line of either checking to see if that status is available to set "True" or how to handle the error so that the macro ignores it.
any help much appreciated
Keith
Using excel 2010 and have an excel spreadsheet that has two sheets,
- data sheet which when refreshed goes off to a SharePoint and refreshes the data
- Overview sheet which has a Pivot table of the data sheet
users add or modify a SharePoint form and one of the fields is "status", available options are New, final approval, manager approved, booked, claimed.
One of the columns in the data sheet is "status" and that is my first row Label in the pivot
I've created a very basic macro which when run switches to the data sheet and refreshes it, switches to the Overview sheet, refreshes the pivot and then sets the required checkbox's in the status filter, however if there is no status of the type I'm trying to set I get the following error
Run-time error '1004'
Unable to get the PivotItems property of the PivotField class
the VB is as follows:
Sheets("Data").Select
Range("F120").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
Sheets("Overview").Select
Range("A6").Select
ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
With ActiveSheet.PivotTables("PivotTable2").PivotFields("status")
.PivotItems("new").Visible = True
.PivotItems("booked").Visible = True
.PivotItems("final approval").Visible = True
.PivotItems("done").Visible = True
.PivotItems("claimed").Visible = True
End With
what I'm looking for therefore is a way for each line of either checking to see if that status is available to set "True" or how to handle the error so that the macro ignores it.
any help much appreciated
Keith