Can I write from VBA directly to the Power Pivot Data Model?

gazpage

Active Member
Joined
Apr 17, 2015
Messages
393
And if not, what is the closest work around.

I have a VBA macro that outputs c.10m rows. I can't output to and Excel table due to the row limit. Ideally I'd like to turn a VBA array directly into a PowerPivot table (or even better overwrite an existing one so that relationships etc would be maintained.)

Failing that I'm thinking of writing to csv and then importing, but it seems like a wasted step.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
I would be very surprised if you can. There is an object model in Excel 2016 but I doubt that includes the ability to to write records given the way power pivot loads data in columns. I suggest you write to csv first, or change from a vba solution to Power Query if possible.
 
Upvote 0
Thanks. That's what I feared. VBA is necessary to at least cycle through by 100 x 5000 scenarios.
 
Upvote 0
If your VBA is running against an Excel or .csv source and the data transformation isn't mathematically complex then it might be possible to replicate your VBA actions in PowerQuery. Without knowing the data or code it's hard to know if you'd be saving time with PowerQuery (assuming the transformations are possible) but you could use Power Update or similar tools to run it as a batch job overnight.
 
Upvote 0
Thanks for the suggestion, but the 'transformations' are a complex project finance model with cashflow waterfalls, forward looking debt drawdowns etc. Not something that can realistically be done in DAX or M. I think I will write out to csv as suggested by Matt.
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,684
Members
449,116
Latest member
HypnoFant

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top