Solved

vba help

Posted on 2014-11-14
2
92 Views
Last Modified: 2014-11-14
Hi

i am looking for a vba code that when i run in a workbook with so many pivot tables, in a new sheet it would create a report like below

Pivot Table Name   like this  Pivottable1
Pivot Table data source SheetName  like Sheet1 etc
Pivot table Data source range address like A1:D400

in addition if it also can put the pivot table data source background color

thanks,.
0
Comment
Question by:Flora
2 Comments
 
LVL 26

Accepted Solution

by:
ProfessorJimJam earned 500 total points
ID: 40443291
here it is

Sub listpp()

 Dim pvt As PivotTable
 Dim iSht As Long
 Dim iRow As Integer

 Application.ScreenUpdating = False
 Set objNewSheet = Worksheets.Add
 objNewSheet.Activate

 iRow = 2
 iSht = 2

 'SET TITLES
 Range("A1").FormulaR1C1 = "Name"
 Range("B1").FormulaR1C1 = "Source"
 Range("C1").FormulaR1C1 = "Refreshed by"
 Range("D1").FormulaR1C1 = "Refreshed"
 Range("E1").FormulaR1C1 = "Sheet"
 Range("F1").FormulaR1C1 = "Location"

 'GET PIVOT DETAILS
 Do While iSht <= Worksheets.Count
 Sheets(iSht).Select

 For Each pvt In ActiveSheet.PivotTables
 objNewSheet.Cells(iRow, 1).Value = pvt.Name
 objNewSheet.Cells(iRow, 2).Value = pvt.SourceData
 objNewSheet.Cells(iRow, 3).Value = pvt.RefreshName
 objNewSheet.Cells(iRow, 4).Value = pvt.RefreshDate
 objNewSheet.Cells(iRow, 5).Value = ActiveSheet.Name
 objNewSheet.Cells(iRow, 6).Value = pvt.TableRange1.Address
 iRow = iRow + 1
 Next

 iSht = iSht + 1
 Loop

 objNewSheet.Activate

 Application.ScreenUpdating = True

 End Sub

Open in new window

0
 
LVL 6

Author Closing Comment

by:Flora
ID: 40443308
thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question