Avatar of joyacv2
joyacv2Flag for Puerto Rico

asked on 

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

Hi,

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
Avatar of x-men
x-men
Flag of Portugal image

ex.:

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

@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


HTH
Regards,
Zack Barresse
Avatar of joyacv2
joyacv2
Flag of Puerto Rico image

ASKER

so, there is no code to manipulate a power view or powerpivot, do you know any other alternative?
ASKER CERTIFIED SOLUTION
Avatar of Zack Barresse
Zack Barresse
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Microsoft Excel
Microsoft Excel

Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.

144K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo