+ Reply to Thread
Results 1 to 4 of 4

Error when creating Pivot table from macro

  1. #1
    Registered User
    Join Date
    01-16-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    9

    Error when creating Pivot table from macro

    Hi guys,

    I'm getting the run-time error "1004" when i run the macro.

    It is saying that the PivotTable field name is not validl; when I go to debug it, the following is highlighted in the VBA.

    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
    "Sheet1!R3C2:R96C8", Version:=xlPivotTableVersion12).CreatePivotTable _
    TableDestination:="Sheet4!R3C1", TableName:="PivotTable1", DefaultVersion _
    :=xlPivotTableVersion12

    Any ideas?

    Thanks

  2. #2
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Error when creating Pivot table from macro

    Hi,

    I think you can't use PivotTable1 as a name, because it is either a reserved name in Excel or there's already another pivot table with the same name.

    edit: I may be wrong though, just an idea.

  3. #3
    Registered User
    Join Date
    01-16-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Error when creating Pivot table from macro

    Thanks for your response, I've tried changing the name of the table but it is still coming up with the same error.

  4. #4
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Error when creating Pivot table from macro

    Maybe these links can help?

    http://www.excelforum.com/excel-gene...e-invalid.html
    > Blank cell for PivotField name (on top of source data column)
    or
    > Hidden column (cell? row?) in source data

    OR

    http://support.microsoft.com/kb/141286
    "This problem occurs when the first row of the range from which the PivotTable is attempting to pull data contains one or more empty cells. "

+ 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