+ Reply to Thread
Results 1 to 4 of 4

Macro to create Pivots

  1. #1
    Registered User
    Join Date
    12-18-2007
    Posts
    3

    Macro to create Pivots

    Hi guys,
    I' trying to create a Macro that creates Pivot tables...

    The problem i'm encountring is that after recording the Macro, when i try to
    re-run it, it doesn't pick all the Fields..

    It's not finding all columns(fields) required.. I picks on only one field..

    I can't figure out what i'm doing worng.

    The code is not too complex.... i'm just trying to create a blank pivot that ready for drag and drop of fields.. !!!

    Plz help !!!!!!




    Sub Pivot_Create_2()
    '
    ' Pivot_Create_2 Macro
    ' Macro recorded 29/01/2008 by Administrator
    '

    '
    Cells.Select
    ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
    "TRACKING!C1:C20").CreatePivotTable TableDestination:="", TableName:= _
    "PivotTable4", DefaultVersion:=xlPivotTableVersion10
    ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
    ActiveSheet.Cells(3, 1).Select
    End Sub

  2. #2
    Forum Contributor
    Join Date
    08-10-2006
    Posts
    723
    hi,

    why do you need a macro to record a pivot?

    steve

  3. #3
    Registered User
    Join Date
    12-18-2007
    Posts
    3
    Well steve, i have to do lots of calculations after i get the pivots..
    i have got the second half to work... wherein i'm calculating thru multiple sheets etc etc...

    the first part of creating a pivot for some reason doesn't want to work...

    i have found a work around and that is by defining the data...
    i tried defining 3/26 fields and it seems to be OK so far....


    Sub Pivot_Create_2()
    '
    ' Pivot_Create_2 Macro
    '
    '


    Dim myPivot As PivotTable, myField As PivotField
    Set myPivot = ActiveSheet.PivotTableWizard
    Set myField = myPivot.PivotFields("WorkFlowName")
    myField.Orientation = xlRowField
    Set myField = myPivot.PivotFields("WorkFlowTaskName")
    myField.Orientation = xlColumnField
    Set myField = myPivot.PivotFields("ActualEndDate")
    myField.Orientation = xlDataField
    Set myField = myPivot.PivotFields("ScheduledEndDate")
    myField.Orientation = xlDataField

    End Sub




    and it seems to work...
    Will post again if i hit any hurdle...

    Thanks heaps for the post though


    Quote Originally Posted by stevekirk
    hi,

    why do you need a macro to record a pivot?

    steve

  4. #4
    Registered User
    Join Date
    08-24-2012
    Location
    Chicago
    MS-Off Ver
    Excel 20013
    Posts
    55

    Re: Macro to create Pivots

    This works too.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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