LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default what is wrong with creating pivottable ?

Hello,

can anyone help me ?

I wrote a VBA sub to create a pivot table based on external data.
when i run this sub the pivot table is created, the fields are OK (th
data field gets the right function & caption).
But, no data is calculated.
When i enter to the wizard of pivot table that was created and go bac
to "GET DATA" the MSquery pops up with the right data.
than i returned to Excel - without doing anything - and suddenly th
pivot table is calculated.

Because the pivot table is created and the right data is filtered
asume that the strings (connstring, querystring etc.) are ok.

the code:

'Sub ImportOB()

Sheets.Add.Name = "OB"
Sheets("OB").Activate

With ActiveWorkbook.PivotCaches.Add(SourceType:=xlExter nal)
.Connection = ConnString
.CommandType = TypeString
.CommandText = QueryString
.CreatePivotTable _
TableDestination:=Sheets("OB").Range("a1"), _
TableName:="OB"
End With

With ActiveSheet.PivotTables("OB")
.SmallGrid = False
.ColumnGrand = False
.RowGrand = False
.PivotCache.SavePassword = True
.PivotCache.BackgroundQuery = True
.AddFields _
RowFields:="ACCOUNTKEY", _
ColumnFields:="DEBITCREDIT"
End With

With ActiveSheet.PivotTables("OB").PivotFields("SUF")
.Orientation = xlDataField
.Function = xlSum
.Caption = "SumOpen"
.NumberFormat = "#,##0"
End With

ActiveWorkbook.ShowPivotTableFieldList = False
Application.CommandBars("PivotTable").Visible = False

End Sub

Thank you
Avne

--
Message posted from http://www.ExcelForum.com

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating PivotTable in Excel2007 Kealkil4 Excel Discussion (Misc queries) 0 March 1st 10 12:30 PM
Problem with creating pivottable Ruben Excel Discussion (Misc queries) 0 August 27th 08 11:45 AM
Creating a PivotTable w/o selecting data in an existing PivotTable Damian Excel Discussion (Misc queries) 6 November 2nd 07 04:44 PM
Creating a database and PivotTable with a Macro sales26 Excel Programming 2 May 19th 04 05:05 PM
Creating a PivotTable in a Different Workbook Bernard[_3_] Excel Programming 1 January 8th 04 03:57 AM


All times are GMT +1. The time now is 09:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"