+ Reply to Thread
Results 1 to 1 of 1

Creating a Pivot Table using a Macro

  1. #1
    Forum Contributor
    Join Date
    08-29-2012
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    155

    Creating a Pivot Table using a Macro

    I am trying to create a macro that will make a pivot table. In the attached sheet, I am starting in the name Angelo Brocato and am recording a macro by going to insert, pivot table, and then grabbing all the data from A:AI. The following is the Macro which can be seen in the workbook. How do I fix this so I do not have to debug it?

    Sub Macro1()
    '
    ' Macro1 Macro
    '
    ' Keyboard Shortcut: Ctrl+m
    '
    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
    "Data!R1C1:R1048576C35", Version:=xlPivotTableVersion14).CreatePivotTable _
    TableDestination:="Angelo Brocato!R4C7", TableName:="PivotTable12", _
    DefaultVersion:=xlPivotTableVersion14
    Sheets("Angelo Brocato").Select
    Cells(4, 7).Select
    ActiveSheet.PivotTables("PivotTable12").AddDataField ActiveSheet.PivotTables( _
    "PivotTable12").PivotFields("Name"), "Count of Name", xlCount
    End Sub
    Attached Files Attached Files

+ 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