+ Reply to Thread
Results 1 to 3 of 3

Assign a macro to create a pivot table

  1. #1
    Registered User
    Join Date
    06-22-2005
    Posts
    2

    Exclamation Assign a macro to create a pivot table

    I am currently creating a macro from a data worksheet but I am receiving an error.


    Initially, I just recorded the macro however when I am running it, i am receiving an addfields method of Pivot Table Class failed.

    ActiveSheet.PivotTables("PivotTable4").AddFields RowFields:="Level 3", _
    ColumnFields:="Date"

    this is code that was having an error and I am not sure what was wrong with it?
    Can someone forward me a sample of the macro code to resolve this?

    Alib

  2. #2
    Tom Ogilvy
    Guest

    Re: Assign a macro to create a pivot table

    I suspect the problem lies in a disconnect in your code and your data. The
    sample code follows the proper syntax for the function. It is possible that
    the condition of the table at the time the code is run does not permit this
    modification. Only you can tell that by working through your code a step at
    a time and examining the situation.

    --
    Regards,
    Tom Ogilvy


    "acsugguiyao" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > I am currently creating a macro from a data worksheet but I am receiving
    > an error.
    >
    >
    > Initially, I just recorded the macro however when I am running it, i am
    > receiving an addfields method of Pivot Table Class failed.
    >
    > ActiveSheet.PivotTables("PivotTable4").AddFields RowFields:="Level 3",
    > _
    > ColumnFields:="Date"
    >
    > this is code that was having an error and I am not sure what was wrong
    > with it?
    > Can someone forward me a sample of the macro code to resolve this?
    >
    > Alib
    >
    >
    > --
    > acsugguiyao
    > ------------------------------------------------------------------------
    > acsugguiyao's Profile:

    http://www.excelforum.com/member.php...o&userid=24519
    > View this thread: http://www.excelforum.com/showthread...hreadid=381168
    >




  3. #3
    Registered User
    Join Date
    06-22-2005
    Posts
    2

    Exclamation

    I am still unable to find out what is wrong...

    this is the whole code. is there a limitation since my rows is ~4000 rows and I just selected 13 columns?

    ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
    "'AS1-C'!C1:C13").CreatePivotTable TableDestination:= _
    "'[Data Comparison - test1.xls]AS1'!R1C1", TableName:="PivotTable10", _
    DefaultVersion:=xlPivotTableVersion10
    ActiveSheet.PivotTables("PivotTable10").AddFields RowFields:="Level 3", _
    ColumnFields:="Date"
    ActiveSheet.PivotTables("PivotTable10").PivotFields("RTF").Orientation = _
    xlDataField
    ActiveWorkbook.ShowPivotTableFieldList = True
    ActiveWorkbook.ShowPivotTableFieldList = False

    Please help

+ 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