Solved

vba help

Posted on 2014-11-14
2
86 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 25

Accepted Solution

by:
ProfessorJimJam earned 500 total points
Comment Utility
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 5

Author Closing Comment

by:Flora
Comment Utility
thanks
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now