Results 1 to 2 of 2

Pivot Table Macro Problems

Threaded View

  1. #1
    Valued Forum Contributor
    Join Date
    11-15-2007
    Location
    England
    MS-Off Ver
    Office Pro Plus 2021
    Posts
    424

    Pivot Table Macro Problems

    Hi,

    This is a macro I recorded using the recorder.

        ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
            "'HOME D&C'!R1C4:R639C21").CreatePivotTable TableDestination:="", TableName _
            :="PivotTable7", DefaultVersion:=xlPivotTableVersion10
        ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
        ActiveSheet.Cells(3, 1).Select
        ActiveSheet.PivotTables("PivotTable7").AddFields RowFields:=Array("FL/BL", _
            "COMMUNITY", "ISBN", "Title", "Data")
        With ActiveSheet.PivotTables("PivotTable7").PivotFields("Net Qty")
            .Orientation = xlDataField
            .Position = 1
        End With
        ActiveSheet.PivotTables("PivotTable7").PivotFields("Net Val").Orientation = _
            xlDataField
        ActiveWorkbook.ShowPivotTableFieldList = True
        Range("C3").Select
        ActiveSheet.PivotTables("PivotTable7").PivotFields("ISBN").Subtotals = Array( _
            False, False, False, False, False, False, False, False, False, False, False, False)
        Columns("C:C").EntireColumn.AutoFit
        Columns("D:D").EntireColumn.AutoFit
        Range("E3").Select
        With ActiveSheet.PivotTables("PivotTable7").DataPivotField
            .Orientation = xlColumnField
            .Position = 1
        End With
        Cells.Select
        Selection.Copy
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
    This is a macro that a member gave me yesterday for a different problem which I have tried in vain to adapt for the above.

        Dim Lr1 As Long
            
        Dim PT  As PivotTable
    
        Lr1 = Range("B" & Rows.Count).End(xlUp).Row
    
        Set PT = ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
                    "'EXPORT OTHER IMPRINTS'!R1C4:R" & Lr1 & "C18").CreatePivotTable(TableDestination:=Sheets.Add.Range("A1"), _
                    DefaultVersion:=xlPivotTableVersion10)
        
        With PT
            .AddFields RowFields:=Array("FL/BL", "COMMUNITY", "ISBN", "Title", "Data")
            With .PivotFields("Net Qty")
                .Orientation = xlDataField
                .Position = 1
            End With
            With .PivotFields("Net Val")
                .Orientation = xlDataField
                .Position = 2
            End With
        End With
    It works so far and then stops. If anyone could help I would be very grateful. I have attached a blank workbook with the headings only.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Problems with sorting andf Pivot Table problems
    By Saturn in forum Excel General
    Replies: 4
    Last Post: 10-07-2012, 07:47 AM
  2. Problems with Pivot table
    By Ozwilly in forum Excel General
    Replies: 7
    Last Post: 02-27-2012, 02:12 AM
  3. [SOLVED] pivot table problems
    By CatherineC in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-21-2006, 07:10 PM
  4. Pivot table problems
    By cailotto@sbcglobal.net in forum Excel General
    Replies: 1
    Last Post: 12-12-2005, 10:40 PM
  5. Pivot Table Problems
    By Rachel Gonsior in forum Excel General
    Replies: 3
    Last Post: 03-21-2005, 04:06 PM

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