Excel 2007 Macro specific table to generic table?

  • Thread starter Thread starter Sue
  • Start date Start date
S

Sue

I have a statement below with "PivotTable5" - How do I make that a generic
pivot table to where it would work with any pivot highlighted?

With ActiveSheet.PivotTables("PivotTable5").PivotFields("Sum of Duration")
.Calculation = xlPercentOfColumn
.NumberFormat = "0%"
 
Hi Sue

Try
With
ActiveSheet.PivotTables(1).PivotFields("Sum of Duration") _
.Calculation = xlPercentOfColumn
.NumberFormat = "0%"
End With


Assuming there is only 1 pivot table on the active sheet
 
Roger,
I have two pivots on the active sheet. I want to highlight the pivot value
area and then change the format. Is there any way to make the selected pivot
(generic - any active pivotTable) the only one I will change the format?--
Sue
 
Hi Sue

The following appears to work fine for me when I select a cell within the PT
first

Dim myname As String

With ActiveSheet
myname = ActiveCell.PivotTable()
End With
With ActiveSheet.PivotTables(myname).PivotFields("Sum of Duration") _
.Calculation = xlPercentOfColumn
.NumberFormat = "0%"
End With

--
Regards
Roger Govier

Sue said:
Roger,
I have two pivots on the active sheet. I want to highlight the pivot value
area and then change the format. Is there any way to make the selected
pivot
(generic - any active pivotTable) the only one I will change the format?--
Sue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top