none
VBA PowerPivot 2013 - Using ModelMeasures.Add RRS feed

  • Question

  • I'm trying to find an alternative way to add a measure (or calculated field), since it seems that ModelMeasures is not supported in excel 2013. I simply doesn't show up in the list of valid objects for Model.

    I tried both methods below and nothing works:

    ' First Method
    Dim PTable As PivotTable
    Set PTable = ActiveSheet.PivotTables("MyPivotTable")
    PTable.CalculatedMembers.Add _
    Name:="ABC", Formula:="=1+1", Type:=xlCalculatedMeasure
    
    ' Second Method
    Dim Mdl As Model
    Dim Tbl As ModelTable
    Set Mdl = ActiveWorkbook.Model
    Set Tbl = Mdl.ModelTables("MyTable")
    Mdl.ModelMeasures.Add "ABC", Tbl, "=1+1"

    Wednesday, February 27, 2019 12:06 AM