Results 1 to 3 of 3

making pivot table in macro

Threaded View

mez_web_l making pivot table in macro 02-21-2010, 10:44 AM
royUK Re: making pivot table in... 02-21-2010, 10:51 AM
royUK Re: making pivot table in... 02-21-2010, 10:53 AM
  1. #1
    Registered User
    Join Date
    02-21-2010
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    1

    making pivot table in macro

    Hi,

    I am building the pivot table in macro in excel 2003. The table is big, it did not work in excel 2000 so I moved to 2003 and I can build it manually and record the macro for it. However in the program (vba) it does not work. I included displayalerts statement to pass a few warnings (message :do you want to replace contents of worksheet ) and it is running through but no data at all on the pivot tables. I am getting just blank pivot table.
    Here is what is going on: It build pivot table and I can see it while it's running. It builds with the data correctly but it put pivot table on the top of the original table. And that's it.
    After it's saved and closed when I open xls file I do not see data - not on new worksheet not on the original worksheet - so looks like it builds pivot table correctly but does not save it in the destination pivot table. I see only empty pivot data with no data at all even without field names.
    The code is below just in case you need it, the saving of xls file is performed later in the main procedure.

    I appreciate any help on this.
    Sub do_pivot(filename)
    '
    
    '
        Application.DisplayAlerts = False
     
        Workbooks(filename).Sheets("R").Select
       
        Cells.Select
        ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
            "R!R1C1:R2657C19").CreatePivotTable TableDestination:="", TableName:= _
            "PivotTable1", DefaultVersion:=xlPivotTableVersion10
            
       
            
            
        ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
        ActiveSheet.Cells(3, 1).Select
      
        ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:=Array( _
            "S", "Sa", "ON1", _
            "Customer Name(STo)", "VN", "PO", "PID", _
            "Prt", "Q", "LS", "D"), PageFields:= _
            "OMB"
        With ActiveSheet.PivotTables("PivotTable1").PivotFields("LR")
            .Orientation = xlDataField
            .Caption = "Sum of LR"
            .Function = xlSum
        End With
     
            
        Application.DisplayAlerts = True
        
        
    End Sub
    Last edited by royUK; 02-21-2010 at 10:52 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1