Ok, I'm having issue where I'm getting an error on one computer that is running a macro, but it's working on just about every other machine I've test it on. For the life of me I cannot figure out why this is occurring.
We are all utilizing Microsoft Excel 2007 for Windows.
The error is:
Run-time error '1004':
Unable to set the ShowDetail property of the PivotItem class
The code is as follows:
The line throwing the error is:
Again, it's work fine on every machine except one.
Furthermore, on the machine that has the issue, if we go directly to the pivot table, you can see the expand button is there, and it is clickable. I would expect that if this error were to occur in the VBA, it'd also occur when you try to directly do what the VBA code is trying to do.
Any help on this would be greatly appreciated!
We are all utilizing Microsoft Excel 2007 for Windows.
The error is:
Run-time error '1004':
Unable to set the ShowDetail property of the PivotItem class
The code is as follows:
Code:
For Each iDataField In iTable.DataFields
For Each iMeasure In iTable.PivotFields("MEASURE").VisibleItems
iTableST.PivotFields("MEASURE").PivotItems(iMeasure.Name).ShowDetail = True
For Each iBrand In iTable.PivotFields("BRAND").VisibleItems
valueUP = iTableST.GetPivotData(curQuarter, "Brand", iBrand, "MEASURE", iMeasure, curQuarter + " ST", "UP").Value
valueDN = iTableST.GetPivotData(curQuarter, "Brand", iBrand, "MEASURE", iMeasure, curQuarter + " ST", "DN").Value
For Each iPivotCell In iDataField.DataRange.Cells
If iPivotCell.PivotCell.ColumnItems.Item(1) = iBrand.Name Then
If iPivotCell.PivotCell.RowItems.Item(1) = iMeasure.Name Then
With iPivotCell.Interior
.PatternColorIndex = xlAutomatic
If valueUP > 0 Then
.Pattern = xlSolid
.Color = 5296274
ElseIf valueDN > 0 Then
.Pattern = xlSolid
.Color = 255
Else
.Pattern = xlNone
End If
End With
'Debug.Print iMeasure.Name + " - " + iBrand.Name + " - " + CStr(valueUP) + " - " + CStr(valueDN) + " - " + CStr(iPivotCell)
End If
End If
Next
Next
iTableST.PivotFields("MEASURE").PivotItems(iMeasure.Name).ShowDetail = False
Next
Next
The line throwing the error is:
Code:
iTableST.PivotFields("MEASURE").PivotItems(iMeasure.Name).ShowDetail = True
Again, it's work fine on every machine except one.
Furthermore, on the machine that has the issue, if we go directly to the pivot table, you can see the expand button is there, and it is clickable. I would expect that if this error were to occur in the VBA, it'd also occur when you try to directly do what the VBA code is trying to do.
Any help on this would be greatly appreciated!