Thanks MarvinP
I got this to do what I want using the below
Sub Macro8()
'
' Macro5 Macro TO WORK ON THIS
'
'
Dim ws As Worksheet
Dim objPT As PivotTable
Dim objPTField As PivotField
Dim PvName As String
PvName = "NE"
For Each ws In Worksheets
ws.Visible = xlSheetVisible
For Each objPT In ws.PivotTables
With objPT.PivotFields("NE")
.PivotItems("A").Visible = True
.PivotItems("B").Visible = False
End With
Next objPT
Next ws
End Sub
but i would like to build on this and have something like the below but I keep getting an error “wrong number of arguments or invalid property assignment”. So I thought it might be a syntax issue? The code below I believe is possibly better it that I am trying to use Variables, which would be better long term for the code
Sub Macro10()
'
' Macro5 Macro TO WORK ON THIS
'
'
Dim ws As Worksheet
Dim objPT As PivotTable
Dim objPTField As PivotField
Dim objPTItem As PivotItem
Dim PvName As String
PvName = "NE"
For Each ws In Worksheets
ws.Visible = xlSheetVisible
For Each objPT In ws.PivotTables
With objPT.objPTItem("NE")
objPTItem("B").Visible = True
objPTItem("A").Visible = False
End With
Next objPT
Next ws
End Sub
Could it be you are looking for "A" in pivotfields(1) which is the Date?
I have fixed this now
This might cause the error as dates and text are different?
I am not looking at dates here, but I will be in another MACRO that I am working on
Also does .ColumnsFields work? ColumnsFields is really PivotFields(2) ?
I have fixed this now
Thanks again
Bookmarks