Marshall Gu
Marshall Gu

Reputation: 137

VBA to Create Multiple Pivot Tables

I have a requirement to create 50 'base' pivot tables out of the same data sheet, so was hoping to write a VBA script to create 50 worksheets and the pivot tables for each. I tried to record a macro capturing the first 5 or so, but when I tried to run it, it crashed due to length of script. (I don't have the error message anymore but can reproduce if needed.) Can this be done with a loop? And if so, can someone please help? Thanks.

Upvotes: 0

Views: 147

Answers (1)

ashdiggedy
ashdiggedy

Reputation: 476

You could simplify things by using code to create 1 new sheet with a base pivot table, then copy that sheet 49 times. From that point, it wouldn't be too difficult to rename the sheets and reference the respective pivot tables using additional code, especially if there's only a single pivot table per sheet.

Upvotes: 1

Related Questions