M
Manish Jaitly
Hi
I need some help on pivot table programming. My purpose is that the vba code
should read a column with names in one excel workbook and select the same
names in a particular pivot field in another excel workbook. There are
hundreds of names and if done manually it takes a lot of time to manually
select the names (pivot items) in the pivot field.
Here is my code
Dim pt As PivotTable
Dim pi2 As PivotItem
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Set ws1 = Workbooks("Quality Monitoring Data1.xls").Worksheets("EMZ
Attributes-Pivot")
Set ws2 = Workbooks("EMZ FOCUS GROUPS 1.xls").Worksheets("Collated EMZ Focus
Groups")
Set pt = ws1.PivotTables("pivottable4")
pt.PivotFields("SE Alias").PivotItems("(Select All)").Visible = False -
I do not see blank so "Select All" must NOT be clicked so that in the
beginning there are no selections and selections can then be made.
For Each c In ws2.Range("b2:b64000")
If c.Offset(0, 2) = "EMEA EMS" And c.Offset(0, 6) = "Green" Then
pt.PivotFields("SE Alias").PivotItems(c).Visible = True
End If
Next c
When I run the above code I get the run time error message 1004 that says
"Unable to get the pivotitems property of the pivot field class"
Please help me out with this error as this work done manually is taking a
lot of my time.
I need some help on pivot table programming. My purpose is that the vba code
should read a column with names in one excel workbook and select the same
names in a particular pivot field in another excel workbook. There are
hundreds of names and if done manually it takes a lot of time to manually
select the names (pivot items) in the pivot field.
Here is my code
Dim pt As PivotTable
Dim pi2 As PivotItem
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Set ws1 = Workbooks("Quality Monitoring Data1.xls").Worksheets("EMZ
Attributes-Pivot")
Set ws2 = Workbooks("EMZ FOCUS GROUPS 1.xls").Worksheets("Collated EMZ Focus
Groups")
Set pt = ws1.PivotTables("pivottable4")
pt.PivotFields("SE Alias").PivotItems("(Select All)").Visible = False -
I do not see blank so "Select All" must NOT be clicked so that in the
beginning there are no selections and selections can then be made.
For Each c In ws2.Range("b2:b64000")
If c.Offset(0, 2) = "EMEA EMS" And c.Offset(0, 6) = "Green" Then
pt.PivotFields("SE Alias").PivotItems(c).Visible = True
End If
Next c
When I run the above code I get the run time error message 1004 that says
"Unable to get the pivotitems property of the pivot field class"
Please help me out with this error as this work done manually is taking a
lot of my time.