Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
azimabadi
Creator III
Creator III

Pivoting in macro

Hi all,

how can i do "Pivoting" in VBScript macro?

that means that for example, i have created a PivotTable with two dimensions in my macro and then i need to send one of this dimensions on horizontal axis.

Best regards

Peyman

1 Solution

Accepted Solutions
azimabadi
Creator III
Creator III
Author

I have found the correct answer. It's like this :

SUB mySUB

     SET chart = ActiveDocument.Activesheet.CreatePivotTable

     chart.AddDimension "Product"

     chart.AddDimension "Year"

     chart.AddExpression "sum(Amount)"

     cp = chart.GetProperties

     cp.TableProperties.NumberOfLeftDimensions = 1

     chart.SetProperties cp

END SUB

View solution in original post

1 Reply
azimabadi
Creator III
Creator III
Author

I have found the correct answer. It's like this :

SUB mySUB

     SET chart = ActiveDocument.Activesheet.CreatePivotTable

     chart.AddDimension "Product"

     chart.AddDimension "Year"

     chart.AddExpression "sum(Amount)"

     cp = chart.GetProperties

     cp.TableProperties.NumberOfLeftDimensions = 1

     chart.SetProperties cp

END SUB