View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
nospaminlich nospaminlich is offline
external usenet poster
 
Posts: 68
Default Help with Pivot Table Code Please

I've got a macro which creates a Pivot Table from a data extract. Because
the data extract varies in size from time to time I've set the Pivot Table
range to 25000 rows.

Everything is fine except:

1) I'm left with "Blanks" as a Heading for each of the fields in the Pivot
table. Whilst I can manually hide these I haven't been able to change the
code so this happens automatically

2) The data extract includes data in currency format which switches to
"General" and data in mmm-yyyy format which switches to dd/mm/yyyy format. I
could write seperate code to select a range and format it after the Pivot
Table has run but I'm nervous about this in case the Pivot Table area changes.

I've added my code below and would really appreciate some help with how to
overcome the two issues above.

Many thanks

-----------------------

Sheets("Summary").Select
Range("A3").Select

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"Extract!R1C1:R25000C10").CreatePivotTable
TableDestination:=Range("A3"), _
TableName:="PivotTable1"
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:=Array( _
"Cost Centre", "Ledger Code"), ColumnFields:="Month"
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Total")
.Orientation = xlDataField
.Caption = "Sum of Total"
.Function = xlSum
End With
Application.CommandBars("PivotTable").Visible = False
End Sub