Solved

vba help

Posted on 2014-11-14
2
93 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

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…
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 …
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

707 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