How to Create a pivot table via applescript?

I tried this but it does not work. Can anybody help?

set PTable to make new pivot table at PTSheet

where"PTSheet" is predefined.

Thanks a lot!

In Excel, presumably, but what version, how is the data to be in the table chosen, etc. Show us your code to date and tell us what doesn’t work.

Hi, yes, it is in Excel. I am using Excel2008. I want to create a pivot table using (get used range of active sheet). The criteria are arranged in columns. So how should I write the code? The raw data and the result I want is something like below.

Material Num Type
23 N
73 R
47 N
94 N
73 R
47 N
94 N

Sum of Balance Type
Material Num N R Grand Total