Results 1 to 3 of 3

How to change coding in Macro for Pivot

Threaded View

  1. #1
    Registered User
    Join Date
    05-09-2014
    MS-Off Ver
    Excel 2003
    Posts
    32

    Question How to change coding in Macro for Pivot

    I'm trying to run a pivot in Macro where the Pivot needs to choose the whole sheet and not a specific range as the data pasted in the sheet may fall in different range or rows however the columns are stable.,

    Below given is the coding for that Macro Recording for Pivot.

    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
            "NewHiVal!R1C1:R719C26", Version:=xlPivotTableVersion15).CreatePivotTable _
            TableDestination:="Pivot!R3C1", TableName:="PivotTable3", DefaultVersion _
            :=xlPivotTableVersion15
           
        With ActiveSheet.PivotTables("PivotTable3").PivotFields("Site")
            .Orientation = xlPageField
            .Position = 1
        End With
        With ActiveSheet.PivotTables("PivotTable3").PivotFields("Item Number")
            .Orientation = xlRowField
            .Position = 1
        End With
        With ActiveSheet.PivotTables("PivotTable3").PivotFields("Description")
            .Orientation = xlRowField
            .Position = 2
        End With
        ActiveSheet.PivotTables("PivotTable3").AddDataField ActiveSheet.PivotTables( _
            "PivotTable3").PivotFields("Qty on Hand"), "Sum of Qty on Hand", xlSum
        ActiveSheet.PivotTables("PivotTable3").AddDataField ActiveSheet.PivotTables( _
            "PivotTable3").PivotFields("Qty in transit"), "Sum of Qty in transit", xlSum
        ActiveSheet.PivotTables("PivotTable3").AddDataField ActiveSheet.PivotTables( _
            "PivotTable3").PivotFields("Qty Non-Nettable"), "Sum of Qty Non-Nettable", _
            xlSum
        ActiveSheet.PivotTables("PivotTable3").AddDataField ActiveSheet.PivotTables( _
            "PivotTable3").PivotFields("Qty on Order"), "Sum of Qty on Order", xlSum
        ActiveSheet.PivotTables("PivotTable3").PivotSelect "Description[All]", _
            xlLabelOnly + xlFirstRow, True
        With ActiveSheet.PivotTables("PivotTable3").PivotFields("Description")
            .Orientation = xlRowField
            .Position = 1
        End With
        ActiveSheet.PivotTables("PivotTable3").PivotSelect "Description[All]", _
            xlLabelOnly + xlFirstRow, True
        With ActiveSheet.PivotTables("PivotTable3").PivotFields("Description")
            .Orientation = xlRowField
            .Position = 2
        End With
        ActiveSheet.PivotTables("PivotTable3").PivotSelect "'Item Number'[All]", _
            xlLabelOnly + xlFirstRow, True
        ActiveSheet.PivotTables("PivotTable3").ShowValuesRow = True
        ActiveSheet.PivotTables("PivotTable3").PivotFields("Item Number").Subtotals = _
            Array(False, False, False, False, False, False, False, False, False, False, False, False)
        ActiveSheet.PivotTables("PivotTable3").PivotFields("Item Number").LayoutForm = _
            xlTabular
    Thanks in advance for the help.,
    Last edited by sudharshan86; 05-09-2014 at 11:59 AM. Reason: Coding

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Error in macro coding for Creating pivot
    By vkaushal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-24-2013, 07:27 PM
  2. [SOLVED] Vb macro coding for transpose - complete coding?
    By Dharani Suresh in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 08-02-2013, 11:16 PM
  3. [SOLVED] Vb macro coding for transpose - complete coding?
    By Dharani Suresh in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-02-2013, 05:04 AM
  4. [SOLVED] Implant macro coding into ASP coding
    By Sam yong in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-15-2005, 06:05 AM
  5. Macro to change a Pivot Table
    By David M in forum Excel General
    Replies: 0
    Last Post: 03-22-2005, 02:06 PM

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