Avatar of joyacv2
joyacv2Flag for Puerto Rico asked on

is possible to make a power view or power pivot using vba?


How can i make a vba code to create a power view or power pivot in excel? The macro recorder don't do anything. Any idea?
Microsoft Excel

Avatar of undefined
Last Comment
Zack Barresse

8/22/2022 - Mon


Sub PowerPivot()
    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
        "Sheet1!R1C1:R4C2", Version:=xlPivotTableVersion12).CreatePivotTable _
        TableDestination:="Sheet1!R1C4", TableName:="PivotTable1", DefaultVersion _
    Cells(1, 4).Select
End Sub
Zack Barresse

@x-men: They're asking for a PowerPivot creation, not a PivotTable.

@joyacv2: You must be using Excel 2010, in which case no, there is no VBA object model for PowerPivot. This was added in Excel 2013, although it's somewhat limited. Here is an example ...
    Workbooks("Book1").Connections.Add2 Name:="LinkedTable_Table1", Description:="", ConnectionString:="WORKSHEET;Book1", _
                                        CommandText:="Book1!Table1", lCmdType:=7, CreateModelConnection:=True, ImportRelationships:=False

Open in new window

Zack Barresse

so, there is no code to manipulate a power view or powerpivot, do you know any other alternative?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Zack Barresse

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question