Hello: I have the following code that toggles field selection on a pivot table. It works fine on windows, but fails on a Mac at the line indicated below. The Mac is updated with the latest version of excel. Any ideas? Thank you!
Failure line:
Full code:
Failure line:
Code:
Set shp = ActiveSheet.Shapes(Application.Caller)
Full code:
Code:
Sub Toggle_Row_Field()
'Add/Remove the field to the pivot table.
'The field is determined by the button text that calls the macro.
Dim pt As PivotTable
Dim pf As PivotField
Dim sField As String
Dim shp As Shape
'Set variables
Set pt = ActiveSheet.PivotTables(1)
Set shp = ActiveSheet.Shapes(Application.Caller)
sField = shp.TextFrame.Characters.Text
'Toggle field
'If visible then hide it
If pt.PivotFields(sField).Orientation = xlRowField Then
pt.PivotFields(sField).Orientation = xlHidden
shp.Fill.ForeColor.Brightness = 0.5
shp.Line.ForeColor.Brightness = 0.5
Else 'Add to Rows area
pt.PivotFields(sField).Orientation = xlRowField
shp.Fill.ForeColor.Brightness = 0
shp.Line.ForeColor.Brightness = 0
End If
End Sub
Last edited by a moderator: