ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pivot Tables and Charts (https://www.excelbanter.com/excel-programming/341748-pivot-tables-charts.html)

LizW

Pivot Tables and Charts
 
I have a button that creates a pivot chart and table. The data consists of
0's and 1's. This is the code I am using ...

With ActiveChart.PivotLayout.PivotFields("0")
.Orientation = xlRowField
.Position = 1
End With
With ActiveChart.PivotLayout.PivotFields("0")
.Orientation = xlDataField
.Position = 1
End With
ActiveChart.PivotLayout.PivotFields("0").Caption = "Types of Reports"


The problem is that the first cell has to show "0" for the macro to work.
Our data could start with "1". How do I make the "0" in parenthesis different
so that it grabs the first cell content as the first field for the pivot
chart and table. Help!!
--
LizW

GB

Pivot Tables and Charts
 
Yeah, instead of using "0" or "1", if you can get by with just having the
first item, and all other pivottable work falls out from there, then you can
use the first item of the list instead of expecting it to be "0", it will be
whatever it will be. :)

With ActiveChart.PivotLayout.PivotFields(1)

Then if you need to step through all pivotfields, you can nest this in a
loop such that
for XYZ = 1 to ActiveChart.PivotLayout.PivotFields.Count

Next XYZ


"LizW" wrote:

I have a button that creates a pivot chart and table. The data consists of
0's and 1's. This is the code I am using ...

With ActiveChart.PivotLayout.PivotFields("0")
.Orientation = xlRowField
.Position = 1
End With
With ActiveChart.PivotLayout.PivotFields("0")
.Orientation = xlDataField
.Position = 1
End With
ActiveChart.PivotLayout.PivotFields("0").Caption = "Types of Reports"


The problem is that the first cell has to show "0" for the macro to work.
Our data could start with "1". How do I make the "0" in parenthesis different
so that it grabs the first cell content as the first field for the pivot
chart and table. Help!!
--
LizW



All times are GMT +1. The time now is 10:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com