Hi All,

I have tried a number of web sites and forums to sort the data in a PivotTable.

I have 3 columns namely WebPage,Url and Hits.

Have to display the column WebPage as the first column, the Pivot sorts the table by the first column by default although the data that is bound to the Pivot is sorted by the last column Hits.

How do i prevent the default sorting happening in the Pivot or how do I custom sort the Pivot Table by the Hits column.

I am building the PivotTable purely by vbscript , I cannot do it in the code behind file.

formname.PivotTable1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\Babli\SiteMetrics\sitemetrics.mdb;User Id=;Password=;"

formname.PivotTable1.CommandText = "SELECT WebPage,Url,Hits from SiteMetricsTable"

I even tried inserting a total column but didnt work

Set ptConstants = frmSiteMetrics.PivotTable1.Constants

Set totNewTotal = vwView.AddTotal("Total Hits", vwView.Fieldsets("Hits").Fields(0), _

vwView.DataAxis.InsertTotal totNewTotal

vwView.RowAxis.Fieldsets("Hits").Fields("Hits").SortDirection = ptConstants.plSortDirectionDescending

Set vwView.RowAxis.Fieldsets("Hits").Fields("Hits").SortOn = vwView.Totals("Total Hits")

where TotalHits is the new extra column that I added to try my luck on sorting.