Results 1 to 3 of 3
  1. #1
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,420
    Thanks
    124
    Thanked 5 Times in 5 Posts

    Pivot Table Macro

    I have tried to record a macro to create a Pivot Table for sheet purchases. The Pivot table was created perfectly when recording the macro (source data sheet “imported data”)



    However, when running the macro a second time, it comes up with run time error 5 and the following code is highlighted ActiveWorkbook.PivotCaches.Create(SourceType:=xlDa tabase, SourceData:= _
    "Imported Data!R1C1:R1048576C14", Version:=xlPivotTableVersion12). _
    CreatePivotTable TableDestination:="Sheet1!R3C1", TableName:="PivotTable1" _
    , DefaultVersion:=xlPivotTableVersion12



    It would be appreciated if you could assist
    Attached Files Attached Files

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts
    Worksheets names with spaces in them need to be enclosed in single quotes:

    (SourceType:=xlDa tabase, SourceData:= _
    "'Imported Data'!R1C1:R1048576C14", Version:=xlPivotTableVersion12). _
    CreatePivotTable TableDestination:="Sheet1!R3C1", TableName:="PivotTable1" _
    , DefaultVersion:=xlPivotTableVersion12


    Steve

  3. #3
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,420
    Thanks
    124
    Thanked 5 Times in 5 Posts
    Hi Steve

    Thanks for the help, much appreciated

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •